From 997c6fb3aa30c0b2a0fa8458b35be3a57420d304 Mon Sep 17 00:00:00 2001 From: izzy Date: Fri, 31 Oct 2025 15:53:38 +0000 Subject: [PATCH] chore: add a failsafe on restart to prevent other exit codes from preventing restart --- server/src/main.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/main.ts b/server/src/main.ts index 19a7161939..ffc8417af1 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -19,6 +19,11 @@ class Workers { */ workers: Partial>; + /** + * Fail-safe in case anything dies during restart + */ + restarting = false; + constructor() { this.workers = {}; } @@ -97,13 +102,16 @@ class Workers { onExit(name: ImmichWorker, exitCode: number | null) { // restart immich server - if (exitCode === 7) { + if (exitCode === 7 || this.restarting) { + this.restarting = true; + console.info(`${name} worker shutdown for restart`); delete this.workers[name]; // once all workers shut down, bootstrap again if (Object.keys(this.workers).length === 0) { this.bootstrap(); + this.restarting = false; } return;