remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.13k stars 1.72k forks source link

[Feature Request] Add a quit (repl) command #2158

Closed EldTM closed 4 months ago

EldTM commented 6 months ago

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.

github-actions[bot] commented 5 months ago

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

EldTM commented 5 months ago

@remy ^Bump

remy commented 5 months ago

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…

EldTM commented 5 months ago

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.

remy commented 5 months ago

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.

github-actions[bot] commented 5 months ago

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

github-actions[bot] commented 4 months ago

Automatically closing this issue due to lack of activity