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.21k stars 1.72k forks source link

Killing the terminal running nodemon doesn't kill the running node process #2095

Closed jeengbe closed 1 year ago

jeengbe commented 1 year ago

Steps to reproduce

Using the simplest alive-check:

const fs = require("fs");

setInterval(() => {
  fs.writeFileSync("log.txt", new Date().toUTCString());
}, 1000);

When killing the terminal via the (see below) kill terminal button, the node process continues to run and happily prints the current date into the file even though the terminal is long gone.

This is not the case when running node index.js directly and killing the terminal.

image

Additional info

Running ps -e | grep node before kill:

26288 pts/4    00:00:00 node
26301 pts/4    00:00:00 node

after kill:

26288 ?        00:00:00 node
26514 ?        00:00:00 node
remy commented 1 year ago

I'm pretty sure that's unavoidable - the terminal nuking doesn't allow time for nodemon to tidy the sub process - so it's not a clean exit.

I genuinely don't think this can be avoided (which is why I'm closing the issue) - I'd be happy to add the FAQ stating this. Sorry I can't be more useful.