This commit is contained in:
jusax23 2021-10-23 16:21:40 +02:00
parent 67fdc60026
commit efc9ec9e29
2 changed files with 75 additions and 82 deletions

View file

@ -1,7 +1,4 @@
import dnc from "./manager.js"; import * as M from "./manager.js";
const M = new dnc(process);
M.addShutdownTask(()=>{ M.addShutdownTask(()=>{
return new Promise(function(res, rej) { return new Promise(function(res, rej) {

View file

@ -1,8 +1,6 @@
const manager = function(process){
var t = this;
async function exitHandler(options, exitCode) { async function exitHandler(options, exitCode) {
t.shutdown().then(()=>{ shutdown().then(()=>{
setTimeout(function() { setTimeout(function() {
process.exit(); process.exit();
}, 1000); }, 1000);
@ -18,11 +16,11 @@ const manager = function(process){
var shutdownTasks = [] var shutdownTasks = []
t.addShutdownTask = function(task,maxDuration=5000){ export const addShutdownTask = function(task,maxDuration=5000){
shutdownTasks.push({t:task,d:maxDuration}); shutdownTasks.push({t:task,d:maxDuration});
}; };
t.shutdown = function(){ export const shutdown = function(){
return new Promise((res,rej)=>{ return new Promise((res,rej)=>{
console.log("Shuting down ..."); console.log("Shuting down ...");
@ -66,8 +64,8 @@ const manager = function(process){
mayShutdown(); mayShutdown();
}); });
}; };
t.saveShutdown = function(){ export const saveShutdown = function(){
t.shutdown().then(() => { shutdown().then(() => {
setTimeout(function() { //some save time setTimeout(function() { //some save time
process.exit(); process.exit();
}, 1000); }, 1000);
@ -77,5 +75,3 @@ const manager = function(process){
}, 10000); }, 10000);
}); });
} }
}
export default manager;