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.28k stars 1.73k forks source link

Different watch/ignore list for when app has crashed #278

Closed dmmalam closed 6 years ago

dmmalam commented 10 years ago

Is this currently possible:

I use nodemon for web dev, and it restarts correctly when my nodejs app changes. I however use middleware for css (less) and js(browserify) that can each watch their respective files and can rebundle them as necessary. I therefore put the client js / css in my nodemon ignore list. However if I make a error on the css/js file which crashes the process, I then have to manually restart nodemon as it won't detect the file change.

Ideally you should be allowed to optionally specify different files to watch/ignore when a process has crashed. Or is there a simple hack around this that I'm missing?

remy commented 10 years ago

Can you mock up a simplified example of what you mean (to attempt to replicate)? On 24 Jan 2014 23:13, "Dharmesh Malam" notifications@github.com wrote:

Is this currently possible:

I use nodemon for web dev, and it restarts correctly when my nodejs app changes. I however use middleware for css (less) and js(browserify) that can each watch their respective files and can rebundle them as necessary. I therefore put the client js / css in my nodemon ignore list. However if I make a error on the css/js file which crashes the process, I then have to manually restart nodemon as it won't detect the file change.

Ideally you should be allowed to optionally specify different files to watch/ignore when a process has crashed. Or is there a simple hack around this that I'm missing?

— Reply to this email directly or view it on GitHubhttps://github.com/remy/nodemon/issues/278 .

dmmalam commented 10 years ago

So for example:

server.js client.js

In server.js you have say watchify to efficiently recomple client.js on file changes.

I would start nodemon with nodemon --ignore client.js server.js

And this works perfectly 90% of the time, any change in server.js will be detected by nodemon, and any change in client.js will be taken care of by watchify. However if I make an syntax error in client.js, it will crash watchify, which will then crash server.js. I will then go and fix the error in client.js, and save but nothing will pick this up and I would have to restart the process.

Two workarounds are:

  1. make nodemon also monitor also client.js and get rid of watchify, however this slows down dev hugely as a full startup can take 10+ secs, whereas a watchify rebundle is 1 or 2 secs.
  2. Put a try/catch around watchify, and restart it when a file changes. However this would duplicate the tricky file watch logic in multiple places, and isn't full proof.

Ideally I could give a crash ignore/watch option. ie nodemon --ignore client.js --crash-watch *.js server.js so watch for changes in server.js, but then it crashes, also monitor for changes in client.js.

Hope this makes sense, it's a rather niche requirement.

stale[bot] commented 6 years 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