dashcam 1.0.1-beta.33 → 1.0.1-beta.34
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 +19 -5
- package/lib/processManager.js +24 -8
- package/package.json +1 -1
|
@@ -55,8 +55,13 @@ function writeUploadResult(result) {
|
|
|
55
55
|
timestamp: Date.now()
|
|
56
56
|
}, null, 2));
|
|
57
57
|
logger.info('Successfully wrote upload result to file');
|
|
58
|
+
// Verify the file was written
|
|
59
|
+
if (fs.existsSync(RESULT_FILE)) {
|
|
60
|
+
const content = fs.readFileSync(RESULT_FILE, 'utf8');
|
|
61
|
+
logger.info('Verified upload result file exists and contains', { content: content.substring(0, 100) });
|
|
62
|
+
}
|
|
58
63
|
} catch (error) {
|
|
59
|
-
logger.error('Failed to write upload result file', { error });
|
|
64
|
+
logger.error('Failed to write upload result file', { error: error.message, stack: error.stack });
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
|
|
@@ -99,10 +104,11 @@ async function runBackgroundRecording() {
|
|
|
99
104
|
}
|
|
100
105
|
isShuttingDown = true;
|
|
101
106
|
|
|
102
|
-
logger.info(`Received ${signal}, stopping background recording
|
|
107
|
+
logger.info(`Received ${signal} signal, stopping background recording...`, { pid: process.pid });
|
|
103
108
|
|
|
104
109
|
try {
|
|
105
110
|
// Stop the recording
|
|
111
|
+
logger.info('Calling stopRecording...');
|
|
106
112
|
const stopResult = await stopRecording();
|
|
107
113
|
|
|
108
114
|
if (stopResult) {
|
|
@@ -128,10 +134,12 @@ async function runBackgroundRecording() {
|
|
|
128
134
|
logger.info('Upload complete', { shareLink: uploadResult.shareLink });
|
|
129
135
|
|
|
130
136
|
// Write upload result for stop command to read
|
|
137
|
+
logger.info('About to write upload result...');
|
|
131
138
|
writeUploadResult({
|
|
132
139
|
shareLink: uploadResult.shareLink,
|
|
133
140
|
replayId: uploadResult.replay?.id
|
|
134
141
|
});
|
|
142
|
+
logger.info('Upload result written successfully');
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
// Update status to indicate recording stopped
|
|
@@ -144,13 +152,19 @@ async function runBackgroundRecording() {
|
|
|
144
152
|
logger.info('Background process exiting successfully');
|
|
145
153
|
process.exit(0);
|
|
146
154
|
} catch (error) {
|
|
147
|
-
logger.error('Error during shutdown:', error);
|
|
155
|
+
logger.error('Error during shutdown:', { error: error.message, stack: error.stack });
|
|
148
156
|
process.exit(1);
|
|
149
157
|
}
|
|
150
158
|
};
|
|
151
159
|
|
|
152
|
-
process.on('SIGINT', () =>
|
|
153
|
-
|
|
160
|
+
process.on('SIGINT', () => {
|
|
161
|
+
logger.info('SIGINT handler triggered');
|
|
162
|
+
handleShutdown('SIGINT');
|
|
163
|
+
});
|
|
164
|
+
process.on('SIGTERM', () => {
|
|
165
|
+
logger.info('SIGTERM handler triggered');
|
|
166
|
+
handleShutdown('SIGTERM');
|
|
167
|
+
});
|
|
154
168
|
|
|
155
169
|
// Keep the process alive
|
|
156
170
|
logger.info('Background recording is now running. Waiting for stop signal...');
|
package/lib/processManager.js
CHANGED
|
@@ -59,22 +59,26 @@ class ProcessManager {
|
|
|
59
59
|
logger.info('Successfully wrote upload result to file');
|
|
60
60
|
// Verify it was written
|
|
61
61
|
if (fs.existsSync(RESULT_FILE)) {
|
|
62
|
-
|
|
62
|
+
const fileSize = fs.statSync(RESULT_FILE).size;
|
|
63
|
+
logger.info('Verified upload result file exists', { size: fileSize });
|
|
63
64
|
} else {
|
|
64
65
|
logger.error('Upload result file does not exist after write!');
|
|
65
66
|
}
|
|
66
67
|
} catch (error) {
|
|
67
|
-
logger.error('Failed to write upload result file', { error });
|
|
68
|
+
logger.error('Failed to write upload result file', { error: error.message, stack: error.stack });
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
readUploadResult() {
|
|
72
73
|
try {
|
|
74
|
+
logger.debug('Checking for upload result file', { path: RESULT_FILE, exists: fs.existsSync(RESULT_FILE) });
|
|
73
75
|
if (!fs.existsSync(RESULT_FILE)) return null;
|
|
74
76
|
const data = fs.readFileSync(RESULT_FILE, 'utf8');
|
|
75
|
-
|
|
77
|
+
const result = JSON.parse(data);
|
|
78
|
+
logger.debug('Successfully read upload result', { shareLink: result.shareLink });
|
|
79
|
+
return result;
|
|
76
80
|
} catch (error) {
|
|
77
|
-
logger.error('Failed to read upload result file', { error });
|
|
81
|
+
logger.error('Failed to read upload result file', { error: error.message, stack: error.stack });
|
|
78
82
|
return null;
|
|
79
83
|
}
|
|
80
84
|
}
|
|
@@ -128,11 +132,23 @@ class ProcessManager {
|
|
|
128
132
|
cleanup(options = {}) {
|
|
129
133
|
const { preserveResult = false } = options;
|
|
130
134
|
try {
|
|
131
|
-
|
|
132
|
-
if (fs.existsSync(
|
|
133
|
-
|
|
135
|
+
logger.debug('Cleanup called', { preserveResult, resultFileExists: fs.existsSync(RESULT_FILE) });
|
|
136
|
+
if (fs.existsSync(PID_FILE)) {
|
|
137
|
+
fs.unlinkSync(PID_FILE);
|
|
138
|
+
logger.debug('Deleted PID file');
|
|
139
|
+
}
|
|
140
|
+
if (fs.existsSync(STATUS_FILE)) {
|
|
141
|
+
fs.unlinkSync(STATUS_FILE);
|
|
142
|
+
logger.debug('Deleted STATUS file');
|
|
143
|
+
}
|
|
144
|
+
if (!preserveResult && fs.existsSync(RESULT_FILE)) {
|
|
145
|
+
fs.unlinkSync(RESULT_FILE);
|
|
146
|
+
logger.debug('Deleted RESULT file');
|
|
147
|
+
} else if (preserveResult && fs.existsSync(RESULT_FILE)) {
|
|
148
|
+
logger.debug('Preserved RESULT file');
|
|
149
|
+
}
|
|
134
150
|
} catch (error) {
|
|
135
|
-
logger.error('Failed to cleanup process files', { error });
|
|
151
|
+
logger.error('Failed to cleanup process files', { error: error.message });
|
|
136
152
|
}
|
|
137
153
|
}
|
|
138
154
|
|