feat: Configure app service to restart automatically in Docker Compose and replace file-based restart trigger with process.exit().

This commit is contained in:
syntaxbullet
2025-12-24 14:28:23 +01:00
parent 2106f06f8f
commit 83984faeae
2 changed files with 4 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ services:
- ./src/db/log:/var/log/postgresql - ./src/db/log:/var/log/postgresql
app: app:
container_name: aurora_app container_name: aurora_app
restart: unless-stopped
image: aurora-app image: aurora-app
build: build:
context: . context: .

View File

@@ -9,7 +9,6 @@ const execAsync = promisify(exec);
// Constants // Constants
const STALE_CONTEXT_MS = 10 * 60 * 1000; // 10 minutes const STALE_CONTEXT_MS = 10 * 60 * 1000; // 10 minutes
const RESTART_TRIGGER_FILE = ".restart_trigger";
export interface RestartContext { export interface RestartContext {
channelId: string; channelId: string;
@@ -77,12 +76,9 @@ export class UpdateService {
// Run without awaiting - it may kill the process immediately // Run without awaiting - it may kill the process immediately
exec(process.env.RESTART_COMMAND).unref(); exec(process.env.RESTART_COMMAND).unref();
} else { } else {
// Fallback to writing a trigger file (avoids polluting source code) // Fallback: exit the process and let Docker/PM2/systemd restart it
try { // Small delay to allow any pending I/O to complete
await writeFile(RESTART_TRIGGER_FILE, Date.now().toString()); setTimeout(() => process.exit(0), 100);
} catch (err) {
console.error("Failed to write restart trigger:", err);
}
} }
} }