dashcam 1.0.1-beta.22 โ 1.0.1-beta.23
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 +17 -18
- package/lib/recorder.js +28 -8
- package/lib/tracking/FileTracker.js +1 -1
- package/package.json +1 -1
- package/test_workflow.sh +19 -14
package/bin/dashcam.js
CHANGED
|
@@ -417,30 +417,29 @@ program
|
|
|
417
417
|
|
|
418
418
|
console.log('Recording stopped successfully');
|
|
419
419
|
|
|
420
|
+
// Wait a moment for upload to complete (background process handles this)
|
|
421
|
+
logger.debug('Waiting for background upload to complete...');
|
|
422
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
423
|
+
|
|
424
|
+
// Try to read the upload result from the background process
|
|
425
|
+
const uploadResult = processManager.readUploadResult();
|
|
426
|
+
logger.debug('Upload result read attempt', { found: !!uploadResult, shareLink: uploadResult?.shareLink });
|
|
427
|
+
|
|
428
|
+
if (uploadResult && uploadResult.shareLink) {
|
|
429
|
+
console.log('๐น Watch your recording:', uploadResult.shareLink);
|
|
430
|
+
// Clean up the result file now that we've read it
|
|
431
|
+
processManager.cleanup();
|
|
432
|
+
process.exit(0);
|
|
433
|
+
}
|
|
434
|
+
|
|
420
435
|
// Check if files still exist - if not, background process already uploaded
|
|
421
436
|
const filesExist = fs.existsSync(result.outputPath) &&
|
|
422
437
|
(!result.gifPath || fs.existsSync(result.gifPath)) &&
|
|
423
438
|
(!result.snapshotPath || fs.existsSync(result.snapshotPath));
|
|
424
439
|
|
|
425
440
|
if (!filesExist) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
logger.debug('Waiting for upload result from background process');
|
|
429
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
430
|
-
|
|
431
|
-
// Try to read the upload result from the background process
|
|
432
|
-
const uploadResult = processManager.readUploadResult();
|
|
433
|
-
logger.debug('Upload result read attempt', { found: !!uploadResult, shareLink: uploadResult?.shareLink });
|
|
434
|
-
|
|
435
|
-
if (uploadResult && uploadResult.shareLink) {
|
|
436
|
-
console.log('๐น Watch your recording:', uploadResult.shareLink);
|
|
437
|
-
// Clean up the result file now that we've read it
|
|
438
|
-
processManager.cleanup();
|
|
439
|
-
} else {
|
|
440
|
-
console.log('โ
Recording uploaded (share link not available)');
|
|
441
|
-
logger.warn('Upload result not available from background process');
|
|
442
|
-
}
|
|
443
|
-
|
|
441
|
+
console.log('โ
Recording uploaded by background process');
|
|
442
|
+
logger.info('Files were cleaned up by background process');
|
|
444
443
|
process.exit(0);
|
|
445
444
|
}
|
|
446
445
|
|
package/lib/recorder.js
CHANGED
|
@@ -531,20 +531,20 @@ export async function stopRecording() {
|
|
|
531
531
|
// Wait for FFmpeg to finish gracefully with realtime encoding
|
|
532
532
|
const gracefulTimeout = setTimeout(() => {
|
|
533
533
|
if (currentRecording && !currentRecording.killed) {
|
|
534
|
-
logger.warn('FFmpeg did not exit gracefully after
|
|
534
|
+
logger.warn('FFmpeg did not exit gracefully after 10s, sending SIGTERM...');
|
|
535
535
|
// If still running, try SIGTERM
|
|
536
536
|
process.kill(currentRecording.pid, 'SIGTERM');
|
|
537
537
|
}
|
|
538
|
-
},
|
|
538
|
+
}, 10000); // Wait longer for graceful shutdown
|
|
539
539
|
|
|
540
|
-
// Wait up to
|
|
540
|
+
// Wait up to 20 seconds for SIGTERM to work
|
|
541
541
|
const hardKillTimeout = setTimeout(() => {
|
|
542
542
|
if (currentRecording && !currentRecording.killed) {
|
|
543
543
|
logger.error('FFmpeg still running after SIGTERM, using SIGKILL...');
|
|
544
544
|
// If still not dead, use SIGKILL as last resort
|
|
545
545
|
process.kill(currentRecording.pid, 'SIGKILL');
|
|
546
546
|
}
|
|
547
|
-
},
|
|
547
|
+
}, 20000); // Longer timeout to avoid killing prematurely
|
|
548
548
|
|
|
549
549
|
// Wait for the process to fully exit
|
|
550
550
|
if (currentRecording) {
|
|
@@ -555,10 +555,30 @@ export async function stopRecording() {
|
|
|
555
555
|
clearTimeout(gracefulTimeout);
|
|
556
556
|
clearTimeout(hardKillTimeout);
|
|
557
557
|
|
|
558
|
-
//
|
|
559
|
-
//
|
|
560
|
-
logger.debug('Waiting for
|
|
561
|
-
|
|
558
|
+
// Wait for filesystem to sync and file to be written
|
|
559
|
+
// Poll for the file to exist with content
|
|
560
|
+
logger.debug('Waiting for temp file to be written...');
|
|
561
|
+
const maxWaitTime = 10000; // Wait up to 10 seconds
|
|
562
|
+
const startWait = Date.now();
|
|
563
|
+
let tempFileReady = false;
|
|
564
|
+
|
|
565
|
+
while (!tempFileReady && (Date.now() - startWait) < maxWaitTime) {
|
|
566
|
+
const tempFile = currentTempFile;
|
|
567
|
+
if (tempFile && fs.existsSync(tempFile)) {
|
|
568
|
+
const stats = fs.statSync(tempFile);
|
|
569
|
+
if (stats.size > 0) {
|
|
570
|
+
logger.debug('Temp file is ready', { size: stats.size });
|
|
571
|
+
tempFileReady = true;
|
|
572
|
+
break;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
// Wait a bit before checking again
|
|
576
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (!tempFileReady) {
|
|
580
|
+
logger.warn('Temp file not ready after waiting, proceeding anyway');
|
|
581
|
+
}
|
|
562
582
|
|
|
563
583
|
// Read temp file path from disk (for cross-process access)
|
|
564
584
|
let tempFile = currentTempFile; // Try in-memory first
|
|
@@ -47,7 +47,7 @@ export class FileTracker {
|
|
|
47
47
|
fs.writeFileSync(this.trackedFile, '', 'utf8');
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
this.tail = new Tail(this.trackedFile, { encoding: '
|
|
50
|
+
this.tail = new Tail(this.trackedFile, { encoding: 'utf8' });
|
|
51
51
|
this.tail.on('line', (line) => {
|
|
52
52
|
const time = Date.now();
|
|
53
53
|
this.eventTimes.push(time);
|
package/package.json
CHANGED
package/test_workflow.sh
CHANGED
|
@@ -46,7 +46,7 @@ RECORDING_START=$(date +%s)
|
|
|
46
46
|
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
47
47
|
echo "๐ด EVENT 1: Recording START at $(date '+%H:%M:%S')"
|
|
48
48
|
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
49
|
-
echo "[EVENT 1] Recording started at $(date '+%H:%M:%S') - TIMESTAMP: $RECORDING_START" >> "$TEMP_FILE"
|
|
49
|
+
echo "[EVENT 1] ๐ด Recording started with emoji at $(date '+%H:%M:%S') - TIMESTAMP: $RECORDING_START" >> "$TEMP_FILE"
|
|
50
50
|
|
|
51
51
|
# Verify recording is actually running
|
|
52
52
|
if ps -p $RECORD_PID > /dev/null; then
|
|
@@ -71,25 +71,25 @@ sleep 3
|
|
|
71
71
|
# Event 2 - after 3 seconds
|
|
72
72
|
echo ""
|
|
73
73
|
echo "๐ก EVENT 2: 3 seconds mark at $(date '+%H:%M:%S')"
|
|
74
|
-
echo "[EVENT 2] 3 seconds elapsed at $(date '+%H:%M:%S')" >> "$TEMP_FILE"
|
|
74
|
+
echo "[EVENT 2] ๐ก 3 seconds elapsed with emoji at $(date '+%H:%M:%S')" >> "$TEMP_FILE"
|
|
75
75
|
sleep 3
|
|
76
76
|
|
|
77
77
|
# Event 3 - after 6 seconds
|
|
78
78
|
echo ""
|
|
79
79
|
echo "๐ข EVENT 3: 6 seconds mark at $(date '+%H:%M:%S')"
|
|
80
|
-
echo "[EVENT 3] 6 seconds elapsed at $(date '+%H:%M:%S')" >> "$TEMP_FILE"
|
|
80
|
+
echo "[EVENT 3] ๐ข 6 seconds elapsed with emoji at $(date '+%H:%M:%S')" >> "$TEMP_FILE"
|
|
81
81
|
sleep 3
|
|
82
82
|
|
|
83
83
|
# Event 4 - after 9 seconds
|
|
84
84
|
echo ""
|
|
85
85
|
echo "๐ต EVENT 4: 9 seconds mark at $(date '+%H:%M:%S')"
|
|
86
|
-
echo "[EVENT 4] 9 seconds elapsed at $(date '+%H:%M:%S')" >> "$TEMP_FILE"
|
|
86
|
+
echo "[EVENT 4] ๐ต 9 seconds elapsed with emoji at $(date '+%H:%M:%S')" >> "$TEMP_FILE"
|
|
87
87
|
sleep 3
|
|
88
88
|
|
|
89
89
|
# Event 5 - after 12 seconds
|
|
90
90
|
echo ""
|
|
91
91
|
echo "๐ฃ EVENT 5: 12 seconds mark at $(date '+%H:%M:%S')"
|
|
92
|
-
echo "[EVENT 5] 12 seconds elapsed at $(date '+%H:%M:%S')" >> "$TEMP_FILE"
|
|
92
|
+
echo "[EVENT 5] ๐ฃ 12 seconds elapsed with emoji at $(date '+%H:%M:%S')" >> "$TEMP_FILE"
|
|
93
93
|
sleep 3
|
|
94
94
|
|
|
95
95
|
# Event 6 - before ending
|
|
@@ -98,7 +98,7 @@ echo "โโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
98
98
|
echo "โซ EVENT 6: Recording END at $(date '+%H:%M:%S')"
|
|
99
99
|
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
100
100
|
RECORDING_END=$(date +%s)
|
|
101
|
-
echo "[EVENT 6] Recording ending at $(date '+%H:%M:%S') - TIMESTAMP: $RECORDING_END" >> "$TEMP_FILE"
|
|
101
|
+
echo "[EVENT 6] โซ Recording ending with emoji at $(date '+%H:%M:%S') - TIMESTAMP: $RECORDING_END" >> "$TEMP_FILE"
|
|
102
102
|
|
|
103
103
|
DURATION=$((RECORDING_END - RECORDING_START))
|
|
104
104
|
echo ""
|
|
@@ -112,8 +112,13 @@ sleep 2
|
|
|
112
112
|
# 6. Stop recording and upload (this will kill the background recording process)
|
|
113
113
|
echo ""
|
|
114
114
|
echo "6. Stopping recording and uploading..."
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
# Check if recording is still active
|
|
116
|
+
if ./bin/dashcam.js status | grep -q "Recording in progress"; then
|
|
117
|
+
./bin/dashcam.js stop
|
|
118
|
+
echo "โ
Recording stopped and uploaded"
|
|
119
|
+
else
|
|
120
|
+
echo "โ ๏ธ Recording already completed (this is expected with background mode)"
|
|
121
|
+
fi
|
|
117
122
|
|
|
118
123
|
echo ""
|
|
119
124
|
echo "๐งน Cleaning up..."
|
|
@@ -140,12 +145,12 @@ echo "3. Verify these events appear at the correct times:"
|
|
|
140
145
|
echo ""
|
|
141
146
|
echo " Time | Terminal Display | Log Entry"
|
|
142
147
|
echo " -------|---------------------------|---------------------------"
|
|
143
|
-
echo " 0:00 | ๐ด EVENT 1 | [EVENT 1] Recording started"
|
|
144
|
-
echo " 0:03 | ๐ก EVENT 2 | [EVENT 2] 3 seconds elapsed"
|
|
145
|
-
echo " 0:06 | ๐ข EVENT 3 | [EVENT 3] 6 seconds elapsed"
|
|
146
|
-
echo " 0:09 | ๐ต EVENT 4 | [EVENT 4] 9 seconds elapsed"
|
|
147
|
-
echo " 0:12 | ๐ฃ EVENT 5 | [EVENT 5] 12 seconds elapsed"
|
|
148
|
-
echo " 0:15 | โซ EVENT 6 | [EVENT 6] Recording ending"
|
|
148
|
+
echo " 0:00 | ๐ด EVENT 1 | [EVENT 1] ๐ด Recording started"
|
|
149
|
+
echo " 0:03 | ๐ก EVENT 2 | [EVENT 2] ๐ก 3 seconds elapsed"
|
|
150
|
+
echo " 0:06 | ๐ข EVENT 3 | [EVENT 3] ๐ข 6 seconds elapsed"
|
|
151
|
+
echo " 0:09 | ๐ต EVENT 4 | [EVENT 4] ๐ต 9 seconds elapsed"
|
|
152
|
+
echo " 0:12 | ๐ฃ EVENT 5 | [EVENT 5] ๐ฃ 12 seconds elapsed"
|
|
153
|
+
echo " 0:15 | โซ EVENT 6 | [EVENT 6] โซ Recording ending"
|
|
149
154
|
echo ""
|
|
150
155
|
echo "4. The log timestamps should match the video timeline exactly"
|
|
151
156
|
echo "5. Each colored event marker should appear in the video"
|