-
Notifications
You must be signed in to change notification settings - Fork 108
/
server.js
48 lines (37 loc) · 1.08 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Module dependencies
*/
var tasks = require('./tasks');
var express = require('express');
// var passport = require('passport');
var _ = require('lodash');
var app = express();
var baseApp = express();
var config = require('./config/config');
baseApp.use(config.baseURL, app);
var server = require('http').Server(baseApp);
require('colors');
var env = process.env.NODE_ENV || 'development';
var dbConfig = require(__dirname + '/config/database')[env];
var npm = require('npm');
// var sticky = require('sticky-session');
var utils = require('./app/utils');
var port = process.env.PORT || 3000;
var startup = require('./tasks/startup');
var cluster = require('cluster');
var debug = require('debug')('lightning:server');
if (cluster.isMaster) {
startup();
}
npm.load(utils.getNPMConfig());
var io = require('socket.io')(server);
io.set('origins', '*:*');
io.on('connection', function(){
debug('a user connected');
});
// Bootstrap application settings
require('./config/express')(app, io);
// Boostrap routes
require('./config/routes')(app);
server.listen(port);
module.exports = server;