dashcam 1.0.1-beta.32 → 1.0.1-beta.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/dashcam.js CHANGED
@@ -136,10 +136,7 @@ async function recordingAction(options, command) {
136
136
  log('Use "dashcam status" to check progress');
137
137
  log('Use "dashcam stop" to stop recording and upload');
138
138
 
139
- // Close stdout/stderr and exit immediately to prevent blocking
140
- // when called from automation scripts with piped output
141
- process.stdout.end();
142
- process.stderr.end();
139
+ // Process can exit now - background process is detached
143
140
  process.exit(0);
144
141
 
145
142
  } catch (error) {
@@ -159,11 +159,19 @@ class ProcessManager {
159
159
  const isWindows = process.platform === 'win32';
160
160
 
161
161
  if (isWindows) {
162
- logger.info('Windows detected, using taskkill to stop process');
162
+ logger.info('Windows detected, attempting graceful shutdown first');
163
163
  try {
164
- // Use taskkill to forcefully stop the process tree on Windows
164
+ // First try graceful shutdown without /F (force) flag
165
+ // This sends CTRL+C which Node.js can handle
165
166
  const { execSync } = await import('child_process');
166
- execSync(`taskkill /PID ${pid} /F /T`, { stdio: 'ignore' });
167
+ try {
168
+ execSync(`taskkill /PID ${pid} /T`, { stdio: 'ignore', timeout: 5000 });
169
+ logger.info('Sent graceful shutdown signal to process');
170
+ } catch (error) {
171
+ // If graceful shutdown fails or times out, force kill
172
+ logger.warn('Graceful shutdown failed, forcing termination');
173
+ execSync(`taskkill /PID ${pid} /F /T`, { stdio: 'ignore' });
174
+ }
167
175
  } catch (error) {
168
176
  logger.warn('Failed to kill process with taskkill', { error: error.message });
169
177
  }
@@ -238,20 +246,11 @@ class ProcessManager {
238
246
  const __dirname = path.dirname(__filename);
239
247
  const backgroundScript = path.join(__dirname, '..', 'bin', 'dashcam-background.js');
240
248
 
241
- // On Windows, we need to ensure stdio is completely detached
242
- const isWindows = process.platform === 'win32';
243
- const spawnOptions = {
249
+ // Spawn a detached background process
250
+ const child = spawn(process.execPath, [backgroundScript, JSON.stringify(options)], {
244
251
  detached: true,
245
252
  stdio: 'ignore'
246
- };
247
-
248
- // On Windows, also create a new process group to fully detach
249
- if (isWindows) {
250
- spawnOptions.windowsHide = true;
251
- }
252
-
253
- // Spawn a detached background process
254
- const child = spawn(process.execPath, [backgroundScript, JSON.stringify(options)], spawnOptions);
253
+ });
255
254
 
256
255
  // Unref so the parent process can exit
257
256
  child.unref();
@@ -263,8 +262,7 @@ class ProcessManager {
263
262
 
264
263
  logger.info('Background process spawned successfully', {
265
264
  pid,
266
- backgroundScript,
267
- platform: process.platform
265
+ backgroundScript
268
266
  });
269
267
 
270
268
  // Wait a moment for the background process to write its status
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.0.1-beta.32",
3
+ "version": "1.0.1-beta.33",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/index.js",
6
6
  "bin": {