getaimeter 0.7.5 → 0.7.6
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/cli.js +20 -0
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -257,6 +257,26 @@ function runStart() {
|
|
|
257
257
|
process.exitCode = 1;
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
260
|
+
|
|
261
|
+
// Clean up stale lock file if the previous process died
|
|
262
|
+
const fs = require('fs');
|
|
263
|
+
const pathMod = require('path');
|
|
264
|
+
const lockFile = pathMod.join(AIMETER_DIR, 'watcher.lock');
|
|
265
|
+
try {
|
|
266
|
+
if (fs.existsSync(lockFile)) {
|
|
267
|
+
const lockData = JSON.parse(fs.readFileSync(lockFile, 'utf8'));
|
|
268
|
+
try {
|
|
269
|
+
process.kill(lockData.pid, 0);
|
|
270
|
+
// PID is alive — watcher is already running
|
|
271
|
+
console.log(`AIMeter watcher is already running (PID ${lockData.pid}).`);
|
|
272
|
+
return;
|
|
273
|
+
} catch {
|
|
274
|
+
// PID is dead — stale lock, remove it
|
|
275
|
+
fs.unlinkSync(lockFile);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} catch {}
|
|
279
|
+
|
|
260
280
|
startNow();
|
|
261
281
|
console.log('AIMeter watcher started.');
|
|
262
282
|
}
|