forked from DiscoTim/shell-map
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
35 lines (29 loc) · 695 Bytes
/
init.js
File metadata and controls
35 lines (29 loc) · 695 Bytes
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
'option strict';
const cluster = require("cluster");
global.config = require("./config");
require("./lib/consts.js");
require("./lib/logger.js");
const logSystem = "master";
require("./lib/exceptionWriter.js")(logSystem);
if (cluster.isWorker) {
switch (process.env.workerType) {
case "shell-map":
require("./lib/shell-map.js");
break;
}
return;
}
(function init() {
spawnWorker();
})();
function spawnWorker() {
var worker = cluster.fork({
workerType: "shell-map"
});
worker.on("exit", function(code, signal) {
log("error", logSystem, "shell-map died, spawning replacement...");
setTimeout(function() {
spawnWorker();
}, 5000);
});
}