chore: add a failsafe on restart to prevent other exit codes from preventing restart

This commit is contained in:
izzy 2025-10-31 15:53:38 +00:00
parent caac2453b6
commit 997c6fb3aa
No known key found for this signature in database
GPG key ID: 5059F398521BB0F6

View file

@ -19,6 +19,11 @@ class Workers {
*/
workers: Partial<Record<ImmichWorker, Worker | ChildProcess>>;
/**
* 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;