forked from mozilla/copyright
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
32 lines (28 loc) · 927 Bytes
/
start.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
var throng = require('throng');
var server = require('./server')();
var workers = process.env.WEB_CONCURRENCY || 1;
function start() {
server.start(function() {
server.log('info', 'Running server at: ' + server.info.uri);
});
var shutdown = () => {
// instruct hapi to stop accepting incoming requests, and to
// wait fifteen seconds before forcefully terminating existing connections.
// We do this so that we don't interrupt in-flight and queued requests
server.stop({
timeout: 15000
},() => {
// wait fifteen seconds before terminating the process (to allow for the existing request timeout to run it's course)
setTimeout(() => {
process.exit(0);
}, 15000);
});
};
process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);
}
// lol @ Infinity actually being used for something meaningful
throng(start, {
workers,
lifetime: Infinity
});