When running the code directly via node index.js the result is as expected
$ node index.js
[scanner] Resuming work
Job 970923B9DDFA472AF33E73F9E00CB8781004360D stalled and will be reprocessed
^CExiting due to signal SIGINT
Shutting down
[service] Disconnecting
[service] TODO: cleanup
Stopping workers
stopWorker()
here
Finished clean shutdown
Actual behaviour
When running via nodemon index.js or nodemon --signal SIGTERM the process is killed too early.
$ nodemon --signal SIGTERM
[nodemon] 3.1.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `node index.js`
[scanner] Resuming work
Job 970923B9DDFA472AF33E73F9E00CB8781004360D stalled and will be reprocessed
^CExiting due to signal SIGINT
Shutting down
[service] Disconnecting
[service] TODO: cleanup
Stopping workers
stopWorker()
Steps to reproduce
I am using async-cleanup to listen for the events. This doesn't appear to do anything special. It hooks into the following signals, then awaits the result of user-code gracefulShutdown before sending a process.exit(0)
Events listened to:
const listenedSignals = [
"SIGBREAK", // Ctrl-Break on Windows
"SIGHUP", // Parent terminal closed
"SIGINT", // Terminal interrupt, usually by Ctrl-C
"SIGTERM", // Graceful termination
"SIGUSR2", // Used by Nodemon
] as const;
It appears that nodemon is not respecting the SIGINT (CTRL + C) signal and is killing the process early.
node@v20.18.0, linux@6.11.3-200.fc40.x86_64
nodemon -v
:3.1.7
embedded bash in VSCode 1.95.2
nodemon --signal SIGTERM
Expected behaviour
When running the code directly via
node index.js
the result is as expectedActual behaviour
When running via
nodemon index.js
ornodemon --signal SIGTERM
the process is killed too early.Steps to reproduce
I am using async-cleanup to listen for the events. This doesn't appear to do anything special. It hooks into the following signals, then
awaits
the result of user-codegracefulShutdown
before sending aprocess.exit(0)
Events listened to:
It appears that
nodemon
is not respecting theSIGINT
(CTRL + C) signal and is killing the process early.