Reload your Node.js application if it's source code changed. Tested on Windows, Mac OSX, Linux.
npm install reloader
To use it just include 'reloader' as usual NodeJS module and put code that must be started after every restart in 'onReload' callback. eg.
var reloader = require('reloader');
reloader({
onReload: function () {
app.listen(3000);
}});
In case if you go to use Reloader with Express framework:
// Reloader setup demonstration
var app = require('express').createServer();
app.configure(function () {
app.use(app.router);
require('reloader')({
watchModules: true,
onStart: function () {
console.log('Started on port: 3000');
},
onReload: function () {
app.listen(3000);
}});
});
app.get('/', function (req, res) {
res.send('Work!');
});
watchModules: false
onRestart: function() {}
onStart: function() {}