2015-02-11 23:21:10 +01:00
|
|
|
var express = require('express.io');
|
|
|
|
var path = require('path');
|
|
|
|
var fs = require('fs');
|
2015-02-12 13:26:47 +01:00
|
|
|
var nodeModel = require('./lib/node');
|
2015-02-12 03:55:09 +01:00
|
|
|
var config;
|
2015-02-11 23:21:10 +01:00
|
|
|
|
|
|
|
var app = express();
|
2015-02-12 13:26:47 +01:00
|
|
|
app.io();
|
2015-02-11 23:21:10 +01:00
|
|
|
|
2015-02-12 03:55:09 +01:00
|
|
|
if(fs.existsSync('./config.js')){
|
|
|
|
config = require('./config');
|
|
|
|
} else {
|
|
|
|
config = require('./config.default');
|
|
|
|
}
|
2015-02-11 23:54:33 +01:00
|
|
|
|
2015-02-12 13:26:47 +01:00
|
|
|
var node = new nodeModel(config);
|
|
|
|
|
|
|
|
console.log(node.stats);
|
|
|
|
|
|
|
|
var gracefulShutdown = function() {
|
|
|
|
console.log("Received kill signal, shutting down gracefully.");
|
|
|
|
|
|
|
|
node.stop();
|
|
|
|
console.log("Closed node watcher");
|
|
|
|
|
|
|
|
setTimeout(function(){
|
|
|
|
console.log("Closed out remaining connections.");
|
|
|
|
process.exit()
|
|
|
|
}, 2*1000);
|
2015-02-11 23:21:10 +01:00
|
|
|
}
|
|
|
|
|
2015-02-12 13:26:47 +01:00
|
|
|
// listen for TERM signal .e.g. kill
|
|
|
|
process.on('SIGTERM', gracefulShutdown);
|
|
|
|
|
|
|
|
// listen for INT signal e.g. Ctrl-C
|
|
|
|
process.on('SIGINT', gracefulShutdown);
|
2015-02-11 23:21:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
module.exports = app;
|