feat: add different signal for sigterm and sigint (#390)

This commit is contained in:
Nikhil
2026-03-02 18:23:22 -08:00
committed by GitHub
parent 053480d753
commit d84feb105c
2 changed files with 10 additions and 1 deletions

View File

@@ -118,7 +118,13 @@ export class Application {
// Immediate exit without graceful shutdown. Chromium may kill us on update/restart,
// and we need to free the port instantly so the HTTP port doesn't keep switching.
process.exit(EXIT_CODES.SUCCESS)
// Exit 0 only for managed shutdowns (POST /shutdown from Chromium).
// Signal kills exit non-zero so Chromium's OnProcessExited restarts us.
const code =
reason === 'SIGTERM' || reason === 'SIGINT'
? EXIT_CODES.SIGNAL_KILL
: EXIT_CODES.SUCCESS
process.exit(code)
}
private initCoreServices(): void {

View File

@@ -16,6 +16,9 @@ export const EXIT_CODES = {
/** Port conflict after retries - Chromium should increment port and restart */
PORT_CONFLICT: 2,
/** Killed by external signal - Chromium should restart */
SIGNAL_KILL: 3,
} as const
export type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES]