Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodemon not respecting graceful shutdown #2238

Open
bugs181 opened this issue Nov 20, 2024 · 0 comments
Open

Nodemon not respecting graceful shutdown #2238

bugs181 opened this issue Nov 20, 2024 · 0 comments

Comments

@bugs181
Copy link

bugs181 commented Nov 20, 2024

  • Versions: [email protected], [email protected]_64
  • nodemon -v: 3.1.7
  • Operating system/terminal environment (powershell, gitshell, etc): embedded bash in VSCode 1.95.2
  • Command you ran: nodemon --signal SIGTERM

Expected behaviour

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant