-
Notifications
You must be signed in to change notification settings - Fork 0
/
socket.js
57 lines (45 loc) · 1.19 KB
/
socket.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
49
50
51
52
53
54
55
56
57
// Dependencies.
if ( typeof process.env.NODE_ENV !== "undefined" && process.env.NODE_ENV === 'production' )
{
require( 'newrelic' );
log.status( 'New Relic loaded' );
}
var express = require( 'express' ),
url = require( 'url' ),
colors = require( 'colors' ),
fs = require( 'fs' ),
Q = require( 'q' ),
model = require( './models/model.js' ),
controller = require( './controllers/controller.js' ),
log = require( './vendor/log.js' ),
config = require( './config.js' ),
port = config.port;
// Wait for model initialization before continuing.
model.ready.then( function ()
{
// App Middlewares.
var app = express();
app.use( express.json() );
app.use( express.urlencoded() );
// Routes.
app.get( '/', function ( req, res )
{
res.send( 200 );
} );
// Server startup and shutdown.
app.listen( port, function ()
{
log.success( 'Listening on port ' + ( '' + port ).underline, 'START' );
} );
// This handler is triggered when you use Control-C on the terminal.
process.on( 'SIGINT', function ()
{
console.log(); // Just to break line.
log.status( 'Shutting down', 'EXIT' );
process.exit();
} );
} ).fail( function ( err )
{
log.error( err, 'INIT' );
process.exit( -1 );
} );