remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development

Home Page:http://nodemon.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Add a quit (repl) command

EldTM opened this issue · comments

  • nodemon -v: 3.0.3
  • node -v: v21.6.0
  • Operating system/terminal environment: Windows 11 Pro / cmd.exe / wt.exe (Windows Terminal) / powershell.exe/pwsh.exe (Power Shell)
  • Using Docker? What image:
  • Command you ran:
    package.json: "scripts": { "start": "nodemon ./bin/www" }
    npm start

Expected behaviour

Typing in 'q', 'quit', or possibly 'x' or 'exit' on the terminal (repl) (similar to the 'rs' command) could allow graceful exit of the guest app and also nodemon itself, taking any cleanup code/hooks into consideration as well.

Actual behaviour

Currently, there doesn't seem to be a good clean way to gracefully quit, especially on Windows. I'm already aware of the possibility of CTRL + C, but it has certain limitations, including when npm start/nodemon is invoked from a batch script.

P.S. Always appreciate your work remy :-)
Thank you.


If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

This has been raised before, and inline with the design principle of fewer features, it's been agreed that it wouldn't be added.

Perhaps if you can elaborate on "I'm already aware of the possibility of CTRL + C, but it has certain limitations" - what limitations are they?

My understanding is ctrl+c is send a kill signal and thusly the chain of processes should shutdown. Certainly nodemon isn't doing anything more than that in the code, sending a kill signal to the subprocess. Adding a "exit"/"q" key would do the exact same thing…

My idea was the possibility of a shutdown/cleanup hook function on the one hand that if possible could be made to be more graceful in shutting down the processes and/or doing additional cleanup work.

The other, main concern was that there were suggestions that the nodemon can spawn multiple instances while restarting due to lack of proper cleanup (graceful shutdown) on Windows. I expect CTRL+C is more effective on linux/nix. If you're sure that CTRL+C properly cleans up everything and doesn't leave a zombie nodemon after itself, then I have no more concerns regarding that part of my rationale.

It's not quite that simple. What's happening when you send ctrl+c, is that nodemon is trapping the signal then doing a controlled shutdown of the spawned process, then trying to work out if it actually shut down, and then nodemon exits itself.

So you see, adding support for an arbitrary command to shut down is no different to ctrl+c, and the result is the same. Zombies will occur, sometimes, but it depends entirely on the system and the software.

I hope that clarifies a bit.

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

Automatically closing this issue due to lack of activity