fix(daemon): keep lifecycle operations on the selected instance

Restart reconstructed launch inputs and address fallback could redirect a home-selected shutdown to another daemon. Let supervisors publish bound endpoints, retain their worker restart contract, and share captured local lifecycle ownership between CLI and Desktop.
This commit is contained in:
Mohamed Boudra
2026-09-09 14:09:53 +02:00
parent fdf3b4b47f
commit 264276880e
166 changed files with 3824 additions and 4467 deletions
@@ -18,13 +18,11 @@ process.title = "Paseo Supervisor";
interface DaemonRunnerConfig {
devMode: boolean;
reclaimStalePidLock: boolean;
workerArgs: string[];
}
function parseConfig(argv: string[]): DaemonRunnerConfig {
let devMode = false;
let reclaimStalePidLock = false;
const workerArgs: string[] = [];
for (const arg of argv) {
@@ -33,13 +31,14 @@ function parseConfig(argv: string[]): DaemonRunnerConfig {
continue;
}
if (arg === "--reclaim-stale-pid-lock") {
reclaimStalePidLock = true;
continue;
throw new Error(
"--reclaim-stale-pid-lock was removed: stop the existing supervisor before starting another.",
);
}
workerArgs.push(arg);
}
return { devMode, reclaimStalePidLock, workerArgs };
return { devMode, workerArgs };
}
function resolveWorkerEntry(): string {
@@ -116,7 +115,6 @@ async function main(): Promise<void> {
try {
await acquirePidLock(paseoHome, null, {
ownerPid: process.pid,
reclaimStaleDesktopLock: config.reclaimStalePidLock,
});
} catch (error) {
if (error instanceof PidLockError) {
@@ -177,6 +175,7 @@ async function main(): Promise<void> {
onWorkerReady: async ({ listen }) => {
await updatePidLock(paseoHome, { listen }, { ownerPid: process.pid });
},
onWorkerExit: () => updatePidLock(paseoHome, { listen: null }, { ownerPid: process.pid }),
onSupervisorExit: releaseLock,
});
requestSupervisorShutdown = supervisor.requestShutdown;