Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
43b4c03c0f | |||
1764a99129 | |||
f3c974b82f |
2 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "nman",
|
"name": "nman",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/nman.js",
|
"main": "dist/nman.js",
|
||||||
"types": "dist/nman.d.ts",
|
"types": "dist/nman.d.ts",
|
||||||
|
|
|
@ -9,10 +9,10 @@ async function exitHandler() {
|
||||||
|
|
||||||
export class ShutdownTasks {
|
export class ShutdownTasks {
|
||||||
static list: ShutdownTasks[][] = [];
|
static list: ShutdownTasks[][] = [];
|
||||||
task: () => Promise<any> | void;
|
task: () => Promise<void> | void;
|
||||||
maxMillis: number;
|
maxMillis: number;
|
||||||
order: number;
|
order: number;
|
||||||
constructor(task: () => Promise<any> | void, maxMillis: number, order: number) {
|
constructor(task: () => Promise<void> | void, maxMillis: number, order: number) {
|
||||||
this.task = task;
|
this.task = task;
|
||||||
this.maxMillis = maxMillis;
|
this.maxMillis = maxMillis;
|
||||||
this.order = order;
|
this.order = order;
|
||||||
|
@ -25,7 +25,7 @@ export class ShutdownTasks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addShutdownTask = function (task: () => Promise<any> | void, maxMillis = 5000, order = 1) {
|
export const addShutdownTask = function (task: () => Promise<void> | void, maxMillis = 5000, order = 1) {
|
||||||
return new ShutdownTasks(task, maxMillis, order);
|
return new ShutdownTasks(task, maxMillis, order);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ export const shutdown = async () => {
|
||||||
const tasks = prios[i][1];
|
const tasks = prios[i][1];
|
||||||
await Promise.allSettled(tasks.map(t => shutdownSingle(t)));
|
await Promise.allSettled(tasks.map(t => shutdownSingle(t)));
|
||||||
}
|
}
|
||||||
process.exit(0);
|
setTimeout(() => process.exit(0), 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { shutdown, addShutdownTask };
|
export default { shutdown, addShutdownTask };
|
Loading…
Reference in a new issue