From fe758ca3196c0a61cc6c0e689cae58a59cae11bd Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Sun, 16 Jul 2023 18:41:43 -0700 Subject: [PATCH] app: do not restart the server if app is closing --- app/src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/index.ts b/app/src/index.ts index c5d78d27..ab60ea68 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -95,10 +95,12 @@ function server() { logger.error(data.toString().trim()) }) - proc.on('exit', () => { + function restart() { logger.info('Restarting the server...') server() - }) + } + + proc.on('exit', restart) proc.on('disconnect', () => { logger.info('Server disconnected. Reconnecting...') @@ -106,6 +108,7 @@ function server() { }) process.on('exit', () => { + proc.off('exit', restart) proc.kill() }) }