-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
48 lines (43 loc) · 1.4 KB
/
index.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
console.error("==========================++++++++++++++============================");
var logger = new (require("./logger"))(__filename, false);
var appConfig = require("./etc/app.json");
var s = require("./localStorage");
var ami = require("./ami");
var args = process.argv.slice(2);
if (args.indexOf("defaults") !== -1) {
s.deleteSavedSettings();
}
/*
} else if (args.indexOf("snapshot") !== -1) {
s.loadSnapshot();
}
*/
//websocket.startLogListener({ port: appConfig.wsLogsPort });
if (process.env.WS_PORT) appConfig.wsPort = process.env.WS_PORT;
ami.on("initialized", function () {
require("./websocket").init({
port: appConfig.wsPort,
allowOrigin: appConfig.allowOrigin,
clientVersion: require("./package").clientVersion,
//validOperators: validOperators,
}, () => {
logger.notice("FessBox WebSocket Server has started on port", appConfig.wsPort);
// exceptions during startup of essential services should be fatal
process.on('uncaughtException', function (err) {
logger.error("uncaughtException", err.stack);
});
/*
process.on("SIGHUP", function () {
logger.notice("SIGHUP received:", "config reload");
});
process.on("SIGUSR1", function () {
logger.notice("SIGUSR1 received:", "scheduled maintenance");
});
*/
process.on("SIGTERM", function () {
logger.notice("SIGTERM received:", "exiting process");
s.saveSnapshot(process.exit);
});
require("./restServer");
});
});