Преглед изворни кода

added delay option to processes

master
mortie пре 7 година
родитељ
комит
6660e6ddce
3 измењених фајлова са 18 додато и 3 уклоњено
  1. 1
    1
      dedaemon.js
  2. 1
    0
      js/parse-conf.js
  3. 16
    2
      modules/process/index.js

+ 1
- 1
dedaemon.js Прегледај датотеку

@@ -12,7 +12,7 @@ var modules = {
};

if (!process.argv[2]) {
console.log("Usage:", process.argv[1], "<config>");
console.error("Usage:", process.argv[1], "<config>");
process.exit(1);
}


+ 1
- 0
js/parse-conf.js Прегледај датотеку

@@ -37,6 +37,7 @@ var configStructure = {
env: [ "object", "null" ],
restart: "bool",
as: [ "string", "null" ],
delay: [ "number", "null" ],
},
},
}

+ 16
- 2
modules/process/index.js Прегледај датотеку

@@ -101,6 +101,7 @@ class Process {
this.child.kill("SIGKILL");
}

this.stopping = false;
cb();
}, 1000);
}
@@ -120,7 +121,11 @@ class ProcessGroup {
}

stop(cb) {
var next = async(this.procs.length, cb);
this.stopping = true;
var next = async(this.procs.length, () => {
this.stopping = false;
cb();
});
this.procs.forEach(p => p.stop(next));
}
}
@@ -164,8 +169,17 @@ function start(conf_, logger_, modules_) {
"Invalid 'as' attribute:",
proc.as);
}
p.start();
procs[proc.name] = p;

if (proc.delay != null) {
setTimeout(() => {
if (!p.stopping)
p.start();
}, proc.delay);
} else {
p.start();
}
});
}


Loading…
Откажи
Сачувај