-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
41 lines (34 loc) · 844 Bytes
/
app.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
var express = require('express'),
path = require('path'),
messageService = require('./lib/message'),
monitoring = require('./lib/monitoring'),
session = require('./lib/session');
var app = express(),
server;
app.configure(function() {
app.use(express.bodyParser());
app.use(monitoring);
session.setup(app);
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public', 'app/')));
});
function start() {
server = app.listen.apply(app, arguments);
messageService.install(app, server);
}
function stop() {
if (server) {
server.close();
}
}
module.exports = {
start: start,
stop: stop
};
if (module === require.main) {
var port = process.argv[2];
port = port ? parseInt(port, 10) : 8080;
start(port, function() {
console.log('App started at http://localhost:' + port + '/');
});
}