-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
79 lines (66 loc) · 1.57 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env node
require("iced-coffee-script/register");
Sync = require("sync");
var services = require("./services");
var getLogger = require("./logger");
var log = getLogger("app");
// compatibility with Windows for interrupt signal
if (process.platform === "win32") {
var rl = require("readline").createInterface({
input: process.stdin,
output: process.stdout
});
rl.on("SIGINT", function() {
return process.emit("SIGINT");
});
}
app = require("./app.iced");
doShutdownAsync = function(cb) {
log.info("App shutdown starting...");
app.shutdown(function() {
log.info("Services shutdown starting...");
services.shutdown(function() {
if (cb && typeof cb === "function")
cb();
});
});
};
process.on("uncaughtException", function(err) {
log.error("Shutting down due to an uncaught exception!", err);
app.shutdownSync();
process.exit(0xFF);
});
process.on("exit", function(e) {
log.debug("Triggered exit", e);
app.shutdownSync();
});
process.on("SIGTERM", function(e) {
log.debug("Caught SIGTERM signal");
app.shutdown(function() {
process.exit(0);
});
});
process.on("SIGINT", function() {
log.debug("Caught SIGINT signal");
app.shutdown(function() {
process.exit(0);
});
});
process.on("SIGHUP", function() {
log.debug("Caught SIGHUP signal");
app.shutdown(function() {
process.exit(0);
});
});
process.on("SIGQUIT", function() {
log.debug("Caught SIGQUIT signal");
app.shutdown(function() {
process.exit(0);
});
});
process.on("SIGABRT", function() {
log.debug("Caught SIGABRT signal");
app.shutdown(function() {
process.exit(0);
});
});