I'm using coffeescript with --watch option to rebuild javascript on changes to .coffee files.
Is it safe to combine that with node-supervisor to restart Node on changes to the compiled javascript?
I'm worried it won't be robust because of atomicity when coffeescript is recompiling multiple files. node-supervisor could jump the gun and restart Node on detecting the first filesystem change. Is it robust enough to realize there were additional changes while it was busy restarting Node?
Is there a better way? Ideally I'd have only one filesystem watcher recompile my coffeescript and restart node.
Create a JavaScript launcher, i.e. run.js
, like this:
require('coffee-script');
require('./launch');
Then run this file with supervisor and appropriate options:
supervisor -e "node|js|coffee" run.js
This worked well for me on Windows.
You can use nodemon, it even has a delay feature (to restart server after a number of seconds have passed), for example:
nodemon --debug ./server.coffee 80
Another good feature of nodemon is ignoring files, example:
# this is my ignore file with a nice comment at the top
/vendor/* # ignore all external submodules
/public/* # static files
./README.md # a specific file
*.css # ignore any CSS files too
Other than that, read the documentation on the github repo and watch this Nodetuts video about nodemon: http://nodetuts.com/tutorials/14-some-nodejs-tools.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With