nodemon -v: 2.0.9
node -v: v16.1.0
- Operating system/terminal environment: macOS Catalina, iTerm 2
- Using Docker? What image: Yes, but I have a non-docker breaking example
- Command you ran:
yarn run nodemon watch.js
I'm trying to write a shutdown handler to gracefully close my mariadb sql client pool, but it never works because the script is killed too soon. I copied the example from the README and changed the signal to SIGTERM but it never lets the shutdown function finish.
If I manually send a kill -s SIGUSR2 <pid> then it will wait for the shutdown script, but nodemon doesn't wait.
My shutdown function uses async/await, but I was able to reproduce with out it. All the below info applies to async/await too (meaning it works with manual kill but not nodemon).
Expected behaviour
The script doesn't get killed by nodemon before it can gracefully shut itself down
Actual behaviour
Nodemon kills the script before my SIGUSR2 script can finish
Steps to reproduce
create a file watch.js:
process.stdin.read();
process.once('SIGUSR2', (signal) => {
for (let i = 1; i <= 10000; i++) {
console.log(i);
}
process.kill(process.pid, signal);
});
Save watch.js to trigger a restart and notice that the logs never reach 10,000 (for me it never goes past 4k). Send a manual kill -s SIGUSR2 <pid> and notice that the logs go to 10k, the script ends and then nodemon restarts it.
If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.
nodemon -v: 2.0.9node -v: v16.1.0yarn run nodemon watch.jsI'm trying to write a shutdown handler to gracefully close my mariadb sql client pool, but it never works because the script is killed too soon. I copied the example from the README and changed the signal to
SIGTERMbut it never lets the shutdown function finish.If I manually send a
kill -s SIGUSR2 <pid>then it will wait for the shutdown script, but nodemon doesn't wait.My shutdown function uses async/await, but I was able to reproduce with out it. All the below info applies to async/await too (meaning it works with manual
killbut not nodemon).Expected behaviour
The script doesn't get killed by nodemon before it can gracefully shut itself down
Actual behaviour
Nodemon kills the script before my
SIGUSR2script can finishSteps to reproduce
create a file
watch.js:Save
watch.jsto trigger a restart and notice that the logs never reach 10,000 (for me it never goes past 4k). Send a manualkill -s SIGUSR2 <pid>and notice that the logs go to 10k, the script ends and then nodemon restarts it.If applicable, please append the
--dumpflag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.