fix(core): update
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartexit',
|
||||
version: '1.0.21',
|
||||
description: 'do things before one exists a process'
|
||||
version: '1.0.22',
|
||||
description: 'A library for performing cleanup operations before exiting a Node.js process, ensuring graceful shutdowns.'
|
||||
}
|
||||
|
50
ts/index.ts
50
ts/index.ts
@ -1,6 +1,56 @@
|
||||
import * as plugins from './smartexit.plugins.js';
|
||||
|
||||
export type TProcessSignal =
|
||||
| 'SIGHUP' // Hangup detected on controlling terminal or death of controlling process
|
||||
| 'SIGINT' // Interrupt from keyboard
|
||||
| 'SIGQUIT' // Quit from keyboard
|
||||
| 'SIGILL' // Illegal Instruction
|
||||
| 'SIGTRAP' // Trace/breakpoint trap
|
||||
| 'SIGABRT' // Abort signal from abort(3)
|
||||
| 'SIGIOT' // IOT trap. A synonym for SIGABRT
|
||||
| 'SIGBUS' // Bus error (bad memory access)
|
||||
| 'SIGFPE' // Floating-point exception
|
||||
| 'SIGKILL' // Kill signal
|
||||
| 'SIGUSR1' // User-defined signal 1
|
||||
| 'SIGSEGV' // Invalid memory reference
|
||||
| 'SIGUSR2' // User-defined signal 2
|
||||
| 'SIGPIPE' // Broken pipe: write to pipe with no readers
|
||||
| 'SIGALRM' // Timer signal from alarm(2)
|
||||
| 'SIGTERM' // Termination signal
|
||||
| 'SIGCHLD' // Child stopped or terminated
|
||||
| 'SIGCONT' // Continue if stopped
|
||||
| 'SIGSTOP' // Stop process
|
||||
| 'SIGTSTP' // Stop typed at terminal
|
||||
| 'SIGTTIN' // Terminal input for background process
|
||||
| 'SIGTTOU' // Terminal output for background process
|
||||
| 'SIGURG' // Urgent condition on socket
|
||||
| 'SIGXCPU' // CPU time limit exceeded
|
||||
| 'SIGXFSZ' // File size limit exceeded
|
||||
| 'SIGVTALRM' // Virtual alarm clock
|
||||
| 'SIGPROF' // Profiling timer expired
|
||||
| 'SIGWINCH' // Window resize signal
|
||||
| 'SIGPOLL' // Pollable event (Sys V). Synonym for SIGIO
|
||||
| 'SIGIO' // I/O now possible (4.2BSD)
|
||||
| 'SIGPWR' // Power failure (System V)
|
||||
| 'SIGINFO' // Information request (some systems)
|
||||
| 'SIGLOST' // Resource lost (unused on most UNIX systems)
|
||||
| 'SIGSYS' // Bad system call (unused on most UNIX systems)
|
||||
| 'SIGUNUSED'; // Synonym for SIGSYS
|
||||
|
||||
export class SmartExit {
|
||||
public static async killTreeByPid(pidArg: number, signalArg: TProcessSignal = 'SIGKILL') {
|
||||
const done = plugins.smartpromise.defer();
|
||||
plugins.treeKill.default(pidArg, signalArg, (err) => {
|
||||
if (err) {
|
||||
done.reject(err);
|
||||
} else {
|
||||
done.resolve();
|
||||
}
|
||||
});
|
||||
await done.promise;
|
||||
}
|
||||
|
||||
// Instance
|
||||
public processesToEnd = new plugins.lik.ObjectMap<plugins.childProcess.ChildProcess>();
|
||||
public cleanupFunctions = new plugins.lik.ObjectMap<() => Promise<any>>();
|
||||
|
||||
|
@ -6,5 +6,13 @@ export { childProcess };
|
||||
// pushrocks scope
|
||||
import * as lik from '@push.rocks/lik';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
|
||||
export { lik, smartdelay };
|
||||
export { lik, smartdelay, smartpromise };
|
||||
|
||||
// third party scope
|
||||
import * as treeKill from 'tree-kill';
|
||||
|
||||
export {
|
||||
treeKill
|
||||
}
|
||||
|
Reference in New Issue
Block a user