shennian 0.2.84 → 0.2.85

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.
@@ -567,21 +567,7 @@ export function startDaemonProcess(opts = {}) {
567
567
  }
568
568
  return;
569
569
  }
570
- if (status.pid !== null && status.running && status.adopted) {
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 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shennian",
3
- "version": "0.2.84",
3
+ "version": "0.2.85",
4
4
  "description": "Shennian — AI Agent Control Plane CLI",
5
5
  "type": "module",
6
6
  "bin": {