From 44fabe65708b21c82bd375f853764393d6c86766 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Fri, 18 Aug 2023 20:26:31 +0530 Subject: [PATCH] feat: exit the container if any of the child processes exit out --- aio_run.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aio_run.mjs b/aio_run.mjs index 3c3538689..61ac48c97 100644 --- a/aio_run.mjs +++ b/aio_run.mjs @@ -52,6 +52,16 @@ fs.rmSync("build.env") const caddyProcess = runChildProcessWithPrefix("caddy", ["run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"], "App/Admin Dashboard Caddy") const backendProcess = runChildProcessWithPrefix("pnpm", ["run", "start:prod"], "Backend Server") +caddyProcess.on("exit", (code) => { + console.log(`Exiting process because Caddy Server exited with code ${code}`) + process.exit(code) +}) + +backendProcess.on("exit", (code) => { + console.log(`Exiting process because Backend Server exited with code ${code}`) + process.exit(code) +}) + process.on('SIGINT', () => { console.log("SIGINT received, exiting...")