shennian 0.2.84 → 0.2.86
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/dist/src/commands/daemon.js +20 -16
- package/package.json +1 -1
|
@@ -250,7 +250,7 @@ function inferDaemonLauncherFromProcess(pid) {
|
|
|
250
250
|
}
|
|
251
251
|
export function isShennianRunServiceCommand(command) {
|
|
252
252
|
const normalized = command.replace(/\\/g, '/').trim();
|
|
253
|
-
return (/^(?:\S*\/)?node\s+\S*(?:\/node_modules\/shennian\/|\/dist\/bin\/shennian\.js)\s+run-service(?:\s|$)/.test(normalized) ||
|
|
253
|
+
return (/^(?:\S*\/)?node\s+\S*(?:\/node_modules\/shennian\/|\/dist\/bin\/shennian\.js|\/bin\/shennian)\s+run-service(?:\s|$)/.test(normalized) ||
|
|
254
254
|
/^(?:\S*\/)?shennian(?:\.cmd)?\s+run-service(?:\s|$)/.test(normalized) ||
|
|
255
255
|
/^(?:\S*\/)?npx(?:\.cmd)?\s+(?:--yes\s+)?shennian\s+run-service(?:\s|$)/.test(normalized));
|
|
256
256
|
}
|
|
@@ -567,21 +567,7 @@ export function startDaemonProcess(opts = {}) {
|
|
|
567
567
|
}
|
|
568
568
|
return;
|
|
569
569
|
}
|
|
570
|
-
|
|
571
|
-
try {
|
|
572
|
-
process.kill(status.pid, 'SIGTERM');
|
|
573
|
-
waitForPidExitSync(status.pid);
|
|
574
|
-
try {
|
|
575
|
-
fs.unlinkSync(PID_FILE);
|
|
576
|
-
}
|
|
577
|
-
catch {
|
|
578
|
-
// The adopted daemon may have cleaned up or another start may have taken over.
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
catch {
|
|
582
|
-
// The adopted orphan may already have exited; continue with a clean start.
|
|
583
|
-
}
|
|
584
|
-
}
|
|
570
|
+
stopAdoptedDaemonForStart(status);
|
|
585
571
|
const logFd = fs.openSync(LOG_FILE, 'a');
|
|
586
572
|
const launch = buildDetachedLaunchSpec(resolveCurrentServiceLaunchSpec());
|
|
587
573
|
const child = spawn(launch.command, launch.args, buildDaemonSpawnOptions(launch, logFd));
|
|
@@ -593,6 +579,23 @@ export function startDaemonProcess(opts = {}) {
|
|
|
593
579
|
console.log(chalk.gray(` Logs: ${LOG_FILE}`));
|
|
594
580
|
}
|
|
595
581
|
}
|
|
582
|
+
function stopAdoptedDaemonForStart(status = getDaemonStatus({ cleanupStale: true })) {
|
|
583
|
+
if (status.pid === null || !status.running || !status.adopted)
|
|
584
|
+
return;
|
|
585
|
+
try {
|
|
586
|
+
process.kill(status.pid, 'SIGTERM');
|
|
587
|
+
waitForPidExitSync(status.pid);
|
|
588
|
+
try {
|
|
589
|
+
fs.unlinkSync(PID_FILE);
|
|
590
|
+
}
|
|
591
|
+
catch {
|
|
592
|
+
// The adopted daemon may have cleaned up or another start may have taken over.
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
catch {
|
|
596
|
+
// The adopted orphan may already have exited; continue with a clean start.
|
|
597
|
+
}
|
|
598
|
+
}
|
|
596
599
|
/**
|
|
597
600
|
* Install the platform-native auto-start service.
|
|
598
601
|
* Returns true if the service was immediately started (so caller can skip startDaemonProcess).
|
|
@@ -722,6 +725,7 @@ async function stopDaemonProcessAndWait(timeoutMs = 5000) {
|
|
|
722
725
|
function enableRemoteAccess(opts = {}) {
|
|
723
726
|
persistServerUrlOverride(resolveServerUrlOverride(opts.api));
|
|
724
727
|
clearRemoteAccessDisabled();
|
|
728
|
+
stopAdoptedDaemonForStart();
|
|
725
729
|
const startedByService = installService();
|
|
726
730
|
if (!startedByService) {
|
|
727
731
|
startDaemonProcess({ quiet: opts.json });
|