aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/index.ts')
-rw-r--r--src/daemon/index.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/daemon/index.ts b/src/daemon/index.ts
index 226a895..916be6c 100644
--- a/src/daemon/index.ts
+++ b/src/daemon/index.ts
@@ -9,6 +9,16 @@ async function main() {
const cdpBridge = createCdpBridge();
ipcServer.onMessage((msg, client) => {
+ // FORK: a client may ask the daemon to exit. /browser-target uses this to
+ // switch browsers: the target is resolved per daemon process, and this one
+ // is already holding a WebSocket to the old browser, so re-reading the
+ // stored target is not enough — the process has to go and be respawned.
+ if (msg.type === "control" && msg.action === "shutdown") {
+ console.log(`[pi-browser-daemon] Shutdown requested by ${client.id}: ${msg.reason ?? "no reason given"}`);
+ void shutdown();
+ return;
+ }
+
if (msg.type !== "request") return;
const send: SendToClient = (cid, resp) => {