Skip to content

Instantly share code, notes, and snippets.

@Janpot
Created July 9, 2014 09:42
Show Gist options
  • Save Janpot/510fcd92e49675682935 to your computer and use it in GitHub Desktop.
Save Janpot/510fcd92e49675682935 to your computer and use it in GitHub Desktop.
var db = null,
server = null;
initialise()
.then(function (_db) {
db = _db
return createServer(db);
})
.then(function (_server) {
server = _server;
return server.listen(3000);
})
.then(function () {
console.log('listening on 3000');
});
process.on('uncaughtexception', function (error) {
console.error(error.stack);
server.close()
.then(function () {
return db.close()
})
.then(function () {
process.exit(1);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment