This repository has been archived by the owner on Nov 19, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to express 4.x (in time for the drama)
- Loading branch information
Showing
3 changed files
with
23 additions
and
280 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,11 @@ | ||
require("coffee-script"); | ||
var forever = require('forever-monitor'); | ||
|
||
//process.env.NODE_ENV = "production"; | ||
|
||
var nconf = require("nconf") | ||
, http = require("http") | ||
, server = require("./index") | ||
, domain = require("domain") | ||
, serverDomain = domain.create(); | ||
|
||
|
||
serverDomain.run(function(){ | ||
http.createServer(function(req, res){ | ||
var reqd = domain.create(); | ||
reqd.add(req); | ||
reqd.add(res); | ||
|
||
// On error dispose of the domain | ||
reqd.on('error', function (error) { | ||
console.error('[ERR]', error.code, error.message, req.url); | ||
reqd.dispose(); | ||
}); | ||
var child = new (forever.Monitor)('index.js', { | ||
max: 10, | ||
}); | ||
|
||
// Pass the request to express | ||
server(req, res); | ||
|
||
}).listen(nconf.get("PORT"), function(){ | ||
console.log("[OK] Server started"); | ||
}); | ||
|
||
child.on('exit', function () { | ||
console.log('[ERR] App killed after 10 fails.'); | ||
}); | ||
|
||
serverDomain.on("error", function (error) { | ||
console.error('[ERR]', "Server level error", error.code, error.message, error); | ||
}) | ||
child.start(); |