-
Notifications
You must be signed in to change notification settings - Fork 0
/
fa.js
59 lines (51 loc) · 1.55 KB
/
fa.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
58
59
/**
* Module dependencies.
*/
var express = require('express')
, http = require('http')
, path = require('path');
var logger = require("./lib/log").getLogger('app');
var app = express();
var port = process.env.PORT || 51998;
// all environments
app.set('port', port);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
//app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({
secret : "sdfhoisduahf9832hrnf9832hnroinsdfj89ajfdosajf990",
// set session timeout
cookie : {
path : '/',
httpOnly : true,
maxAge : 3600000
}
}));
app.use(express.methodOverride());
app.use(express.static(path.join(__dirname, 'public')));
app.use(app.router);
// schedule job to clear data
var scheduledJob;
function setupScheduledJob(code, signal) {
if (scheduledJob) {
logger.info('Scheduled process ' + scheduledJob.pid + ' is dead with signal: ' + signal);
logger.info('try to restart scheduled process');
}
scheduledJob = require('child_process').fork(__dirname + '/lib/data-rebuild-schedule/data-rebuild-schedule.js');
logger.info('Scheduled process started successfully.');
scheduledJob.on('exit', setupScheduledJob);
}
setupScheduledJob();
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
// dispatch routes
var dispatcher = require("./dispatcher");
dispatcher.dispatch(app);
http.createServer(app).listen(port, function() {
console.log("attendee listening on port %d in %s mode", port, app.settings.env);
});