Hi, I'd like to share with you a module that I've made trying to implements the base of a robust web server that never breaks and can shutdown gracefully even using workers. These 2 reasons were my primary goal.
The module is: grace <https://github.com/Gagle/Node-Grace> The base of any web server: var express = require ("express"); var grace = require ("../lib/grace"); var app = grace.create (); //Default error handler app.on ("error", function (error){ console.error (error); }); app.on ("start", function (){ var ex = express (); //Request error handler, this should be the first middleware ex.use (app.errorHandler (function (error, req, res, preventDefault){ //Here you'll typically send to the user a 500 error res.send (500); })); //Middleware ex.use (function (req, res, next){ res.send (200); }); //Express error handler, this should be the last middleware ex.use (app.redirectError ()); ex.listen (1337, "localhost"); }); app.on ("shutdown", function (cb){ //Clean up console.log ("shutting down"); cb (); }); app.on ("exit", function (code){ console.log ("bye (" + code + ")"); }); app.timeout (1000, function (){ console.error ("timed out, forcing shutdown"); }); app.start (); I'm using it (with workers) on a distributed web app with big data. What do you think? Excellent, good, bad or terrible? -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
