fix(daemon): tear down daemon when destroying all servers with no entries
This commit is contained in:
@@ -203,6 +203,12 @@ async function handle(req: DaemonRequest): Promise<DaemonResponse> {
|
||||
for (const entry of toDestroy) {
|
||||
evict(entry, "manual destroy");
|
||||
}
|
||||
// Full Shutdown - If destroying all servers and nothing is left
|
||||
// (including the case where no entries existed), tear down the
|
||||
// daemon so it doesn't sit idle.
|
||||
if (!req.serverId && entries.size === 0) {
|
||||
setImmediate(() => shutdownDaemon("destroy all"));
|
||||
}
|
||||
return {
|
||||
id: req.id,
|
||||
ok: true,
|
||||
@@ -223,8 +229,6 @@ async function handle(req: DaemonRequest): Promise<DaemonResponse> {
|
||||
error: (err as Error)?.message ?? String(err),
|
||||
};
|
||||
}
|
||||
// Exhaustiveness - Should be unreachable given the union above.
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
|
||||
// Handle Connection - Reads NDJSON from a client socket; each line is one
|
||||
|
||||
Reference in New Issue
Block a user