forked from YahooArchive/guerilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (36 loc) · 813 Bytes
/
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
/*
* Guerilla
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the MIT License.
*
* Entry point for the Guerilla server.
*/
require('./lib/globals');
var argv = require('yargs').argv;
if (argv.master) {
require('./master.js');
}
else if (argv.worker) {
require('./worker.js');
}
else {
logger.e('Must run with --master or --worker.');
process.exit();
}
function shutdown (callback) {
var queue = require('./lib/queue');
queue.shutdown(callback);
}
process.on('SIGINT', function () {
logger.w('\nSIGINT --- EXITING');
shutdown(process.exit);
});
process.on('SIGTERM', function () {
logger.w('\nSIGTERM --- EXITING');
shutdown(process.exit);
});
process.on('uncaughtException', function (ex) {
logger.e('EXITING: Uncaught Exception');
logger.e(ex.stack);
shutdown(process.exit);
});