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

@@ -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);
}
}