dashcam 1.3.15-beta → 1.3.17-beta
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-background.js +23 -5
- package/bin/dashcam.js +5 -4
- package/lib/processManager.js +13 -2
- package/package.json +1 -1
|
@@ -11,8 +11,8 @@ import fs from 'fs';
|
|
|
11
11
|
import path from 'path';
|
|
12
12
|
import os from 'os';
|
|
13
13
|
|
|
14
|
-
// Get process directory for status files
|
|
15
|
-
const PROCESS_DIR = path.join(os.
|
|
14
|
+
// Get process directory for status files (system temp for cross-session access)
|
|
15
|
+
const PROCESS_DIR = path.join(os.tmpdir(), 'dashcam-cli');
|
|
16
16
|
const STATUS_FILE = path.join(PROCESS_DIR, 'status.json');
|
|
17
17
|
const RESULT_FILE = path.join(PROCESS_DIR, 'upload-result.json');
|
|
18
18
|
|
|
@@ -28,6 +28,13 @@ const options = JSON.parse(optionsJson);
|
|
|
28
28
|
// Enable verbose logging in background
|
|
29
29
|
setVerbose(true);
|
|
30
30
|
|
|
31
|
+
console.log('[Background] Process started', {
|
|
32
|
+
pid: process.pid,
|
|
33
|
+
platform: process.platform,
|
|
34
|
+
processDir: PROCESS_DIR,
|
|
35
|
+
statusFile: STATUS_FILE
|
|
36
|
+
});
|
|
37
|
+
|
|
31
38
|
logger.info('Background recording process started', {
|
|
32
39
|
pid: process.pid,
|
|
33
40
|
options
|
|
@@ -43,7 +50,7 @@ function writeStatus(status) {
|
|
|
43
50
|
platform: process.platform
|
|
44
51
|
};
|
|
45
52
|
|
|
46
|
-
|
|
53
|
+
console.log('[Background] Writing status file:', {
|
|
47
54
|
statusFile: STATUS_FILE,
|
|
48
55
|
pid: statusData.pid,
|
|
49
56
|
isRecording: statusData.isRecording,
|
|
@@ -54,18 +61,20 @@ function writeStatus(status) {
|
|
|
54
61
|
|
|
55
62
|
// Verify it was written
|
|
56
63
|
if (fs.existsSync(STATUS_FILE)) {
|
|
57
|
-
|
|
64
|
+
console.log('[Background] Status file written and verified:', STATUS_FILE);
|
|
58
65
|
|
|
59
66
|
// Read it back to verify content
|
|
60
67
|
const writtenContent = fs.readFileSync(STATUS_FILE, 'utf8');
|
|
61
|
-
|
|
68
|
+
console.log('[Background] Status file content verification:', {
|
|
62
69
|
contentLength: writtenContent.length,
|
|
63
70
|
parseable: true
|
|
64
71
|
});
|
|
65
72
|
} else {
|
|
73
|
+
console.error('[Background] Status file does not exist after write!', STATUS_FILE);
|
|
66
74
|
logger.error('Status file does not exist after write!', { statusFile: STATUS_FILE });
|
|
67
75
|
}
|
|
68
76
|
} catch (error) {
|
|
77
|
+
console.error('[Background] Failed to write status file:', error.message);
|
|
69
78
|
logger.error('Failed to write status file in background process', {
|
|
70
79
|
error: error.message,
|
|
71
80
|
stack: error.stack,
|
|
@@ -102,9 +111,12 @@ async function runBackgroundRecording() {
|
|
|
102
111
|
};
|
|
103
112
|
|
|
104
113
|
logger.info('Starting recording with options', { recordingOptions });
|
|
114
|
+
console.log('[Background] Starting recording with options:', recordingOptions);
|
|
105
115
|
|
|
106
116
|
recordingResult = await startRecording(recordingOptions);
|
|
107
117
|
|
|
118
|
+
console.log('[Background] Recording started, writing status file...');
|
|
119
|
+
|
|
108
120
|
// Write status to track the recording
|
|
109
121
|
writeStatus({
|
|
110
122
|
isRecording: true,
|
|
@@ -118,6 +130,12 @@ async function runBackgroundRecording() {
|
|
|
118
130
|
outputPath: recordingResult.outputPath,
|
|
119
131
|
startTime: recordingResult.startTime
|
|
120
132
|
});
|
|
133
|
+
|
|
134
|
+
console.log('[Background] Recording started successfully', {
|
|
135
|
+
outputPath: recordingResult.outputPath,
|
|
136
|
+
startTime: recordingResult.startTime,
|
|
137
|
+
pid: process.pid
|
|
138
|
+
});
|
|
121
139
|
|
|
122
140
|
// Set up signal handlers for graceful shutdown
|
|
123
141
|
const handleShutdown = async (signal) => {
|
package/bin/dashcam.js
CHANGED
|
@@ -399,7 +399,7 @@ program
|
|
|
399
399
|
platform: process.platform,
|
|
400
400
|
cwd: process.cwd(),
|
|
401
401
|
pid: process.pid,
|
|
402
|
-
processDir: require('os').
|
|
402
|
+
processDir: require('path').join(require('os').tmpdir(), 'dashcam-cli')
|
|
403
403
|
});
|
|
404
404
|
|
|
405
405
|
const isActive = processManager.isRecordingActive();
|
|
@@ -409,13 +409,13 @@ program
|
|
|
409
409
|
console.log('No active recording to stop');
|
|
410
410
|
logger.warn('Stop command called but no active recording found', {
|
|
411
411
|
platform: process.platform,
|
|
412
|
-
statusFile: require('path').join(require('os').
|
|
413
|
-
statusFileExists: require('fs').existsSync(require('path').join(require('os').
|
|
412
|
+
statusFile: require('path').join(require('os').tmpdir(), 'dashcam-cli', 'status.json'),
|
|
413
|
+
statusFileExists: require('fs').existsSync(require('path').join(require('os').tmpdir(), 'dashcam-cli', 'status.json'))
|
|
414
414
|
});
|
|
415
415
|
|
|
416
416
|
// Try to read and display status file for debugging
|
|
417
417
|
try {
|
|
418
|
-
const statusPath = require('path').join(require('os').
|
|
418
|
+
const statusPath = require('path').join(require('os').tmpdir(), 'dashcam-cli', 'status.json');
|
|
419
419
|
if (require('fs').existsSync(statusPath)) {
|
|
420
420
|
const statusContent = require('fs').readFileSync(statusPath, 'utf8');
|
|
421
421
|
logger.debug('Status file contents', { content: statusContent });
|
|
@@ -423,6 +423,7 @@ program
|
|
|
423
423
|
console.log('Status file location:', statusPath);
|
|
424
424
|
} else {
|
|
425
425
|
console.log('Status file does not exist');
|
|
426
|
+
console.log('Expected status file location:', statusPath);
|
|
426
427
|
}
|
|
427
428
|
} catch (err) {
|
|
428
429
|
logger.error('Failed to read status file for debugging', { error: err.message });
|
package/lib/processManager.js
CHANGED
|
@@ -8,8 +8,8 @@ import { logger } from './logger.js';
|
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
|
|
11
|
-
// Use
|
|
12
|
-
const PROCESS_DIR = path.join(os.
|
|
11
|
+
// Use system temp directory for cross-session communication
|
|
12
|
+
const PROCESS_DIR = path.join(os.tmpdir(), 'dashcam-cli');
|
|
13
13
|
const STATUS_FILE = path.join(PROCESS_DIR, 'status.json');
|
|
14
14
|
const RESULT_FILE = path.join(PROCESS_DIR, 'upload-result.json');
|
|
15
15
|
|
|
@@ -161,6 +161,10 @@ class ProcessManager {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
isRecordingActive() {
|
|
164
|
+
console.log('[DEBUG] Checking if recording is active...');
|
|
165
|
+
console.log('[DEBUG] Status file path:', STATUS_FILE);
|
|
166
|
+
console.log('[DEBUG] Status file exists:', fs.existsSync(STATUS_FILE));
|
|
167
|
+
|
|
164
168
|
logger.debug('Checking if recording is active...', {
|
|
165
169
|
statusFile: STATUS_FILE,
|
|
166
170
|
processDir: PROCESS_DIR,
|
|
@@ -169,6 +173,8 @@ class ProcessManager {
|
|
|
169
173
|
|
|
170
174
|
const status = this.readStatus();
|
|
171
175
|
|
|
176
|
+
console.log('[DEBUG] Status read result:', status);
|
|
177
|
+
|
|
172
178
|
logger.debug('Status check result', {
|
|
173
179
|
hasStatus: !!status,
|
|
174
180
|
hasPid: !!(status && status.pid),
|
|
@@ -178,23 +184,27 @@ class ProcessManager {
|
|
|
178
184
|
});
|
|
179
185
|
|
|
180
186
|
if (!status) {
|
|
187
|
+
console.log('[DEBUG] No status found - recording not active');
|
|
181
188
|
logger.debug('No status found - recording not active');
|
|
182
189
|
return false;
|
|
183
190
|
}
|
|
184
191
|
|
|
185
192
|
if (!status.pid) {
|
|
193
|
+
console.log('[DEBUG] Status has no PID - marking as completed');
|
|
186
194
|
logger.debug('Status has no PID - marking as completed');
|
|
187
195
|
this.markStatusCompleted({ reason: 'no_pid_in_status' });
|
|
188
196
|
return false;
|
|
189
197
|
}
|
|
190
198
|
|
|
191
199
|
const processRunning = this.isProcessRunning(status.pid);
|
|
200
|
+
console.log('[DEBUG] Process running check:', { pid: status.pid, isRunning: processRunning });
|
|
192
201
|
logger.debug('Process running check', {
|
|
193
202
|
pid: status.pid,
|
|
194
203
|
isRunning: processRunning
|
|
195
204
|
});
|
|
196
205
|
|
|
197
206
|
if (!processRunning) {
|
|
207
|
+
console.log('[DEBUG] Process not running - marking as completed:', { pid: status.pid });
|
|
198
208
|
logger.debug('Process not running - marking as completed', {
|
|
199
209
|
pid: status.pid,
|
|
200
210
|
wasRecording: status.isRecording
|
|
@@ -207,6 +217,7 @@ class ProcessManager {
|
|
|
207
217
|
return false;
|
|
208
218
|
}
|
|
209
219
|
|
|
220
|
+
console.log('[DEBUG] Recording active status:', { isRecording: status.isRecording, pid: status.pid });
|
|
210
221
|
logger.debug('Recording active status', {
|
|
211
222
|
isRecording: status.isRecording,
|
|
212
223
|
pid: status.pid
|