-
Notifications
You must be signed in to change notification settings - Fork 9
simple express js example
shimondoodkin edited this page Nov 6, 2010
·
2 revisions
expresstest\autoexit.js: - the autoexit.js from the auto restart git expresstest\nodejs.sh: - the nodejs.sh from the auto restart git
expresstest\server.js:
var app = require('express').createServer();
app.get('/', function(req, res){
res.send('hello world');
});
app.listen(3000);
// exit if any js file or template file is changed.
// it is ok because this script encapsualated in a batch while(true);
// so it runs again after it exits.
var autoexit_watch=require('./autoexit').watch;
//
var on_autoexit=function (filename) { } // if it returns false it means to ignore exit this time;
autoexit_watch(__dirname,".js", on_autoexit);
//autoexit_watch(__dirname+"/templates",".html", on_autoexit);
I have executed inside expresstest directory : ./nodejs.sh changed something in the server.js while it was running and it restarted so it worked ok.