From 83984faeaea4852f3f25237f8a7e8251c15cc4c4 Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Wed, 24 Dec 2025 14:28:23 +0100 Subject: [PATCH] feat: Configure app service to restart automatically in Docker Compose and replace file-based restart trigger with `process.exit()`. --- docker-compose.yml | 1 + src/modules/admin/update.service.ts | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0a6f631..a227f47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,7 @@ services: - ./src/db/log:/var/log/postgresql app: container_name: aurora_app + restart: unless-stopped image: aurora-app build: context: . diff --git a/src/modules/admin/update.service.ts b/src/modules/admin/update.service.ts index c7823ce..38fe614 100644 --- a/src/modules/admin/update.service.ts +++ b/src/modules/admin/update.service.ts @@ -9,7 +9,6 @@ const execAsync = promisify(exec); // Constants const STALE_CONTEXT_MS = 10 * 60 * 1000; // 10 minutes -const RESTART_TRIGGER_FILE = ".restart_trigger"; export interface RestartContext { channelId: string; @@ -77,12 +76,9 @@ export class UpdateService { // Run without awaiting - it may kill the process immediately exec(process.env.RESTART_COMMAND).unref(); } else { - // Fallback to writing a trigger file (avoids polluting source code) - try { - await writeFile(RESTART_TRIGGER_FILE, Date.now().toString()); - } catch (err) { - console.error("Failed to write restart trigger:", err); - } + // Fallback: exit the process and let Docker/PM2/systemd restart it + // Small delay to allow any pending I/O to complete + setTimeout(() => process.exit(0), 100); } }