From 747567566c46db0ff50be0cb02c54e7330d19703 Mon Sep 17 00:00:00 2001 From: Bobby Date: Sat, 25 Feb 2023 18:16:21 +0700 Subject: [PATCH] fix: catch SIGINT signal --- lolisafe.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lolisafe.js b/lolisafe.js index 500e1b2..a918236 100644 --- a/lolisafe.js +++ b/lolisafe.js @@ -9,6 +9,11 @@ process.on('unhandledRejection', error => { logger.error(error, { prefix: 'Unhandled Rejection (Promise): ' }) }) +process.once('SIGINT', () => { + logger.log('SIGINT signal received, exiting lolisafe\u2026') + process.exit(0) +}) + // Change working directory into the directory that contains lolisafe.js try { const { chdir, cwd } = require('process') @@ -425,8 +430,6 @@ safe.use('/api', api) } catch (error) { process.stderr.write(`${error.stack}\n`) } - }).on('SIGINT', () => { - process.exit(0) }) logger.log(utils.stripIndents(`!!! DEVELOPMENT MODE !!! [=] Nunjucks will auto rebuild (not live reload)