Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 36 37 38 39 | 1x 1x 1x 1x 1x 1x 1x | import { Service } from '../../container';
import { BootstrapLogger } from '../bootstrap-logger';
import { Injector } from '../../decorators/injector/injector.decorator';
import { Observable, Subject } from 'rxjs';
export type NodejsEvents = 'beforeExit' | 'disconnect' | 'exit' | 'rejectionHandled' |
'uncaughtException' | 'unhandledRejection' | 'warning' | 'message' | 'newListener' | 'removeListener';
export type Signals =
'SIGABRT' | 'SIGALRM' | 'SIGBUS' | 'SIGCHLD' | 'SIGCONT' | 'SIGFPE' | 'SIGHUP' | 'SIGILL' | 'SIGINT' | 'SIGIO' |
'SIGIOT' | 'SIGKILL' | 'SIGPIPE' | 'SIGPOLL' | 'SIGPROF' | 'SIGPWR' | 'SIGQUIT' | 'SIGSEGV' | 'SIGSTKFLT' |
'SIGSTOP' | 'SIGSYS' | 'SIGTERM' | 'SIGTRAP' | 'SIGTSTP' | 'SIGTTIN' | 'SIGTTOU' | 'SIGUNUSED' | 'SIGURG' |
'SIGUSR1' | 'SIGUSR2' | 'SIGVTALRM' | 'SIGWINCH' | 'SIGXCPU' | 'SIGXFSZ' | 'SIGBREAK' | 'SIGLOST' | 'SIGINFO';
@Service()
export class ExitHandlerService {
errorHandler: Subject<any> = new Subject();
@Injector(BootstrapLogger) private logger: BootstrapLogger;
init() {}
exitHandler(options, err) {
this.errorHandler.next(err);
if (options.cleanup) {
this.logger.logExitHandler('AppStopped');
}
if (err) console.log(err.stack);
if (options.exit) {
this.logger.logExitHandler('Unhandled error rejection');
}
}
onExitApp(events: Array<Signals | NodejsEvents>) {
return new Observable(o => {
process.on(<any>event, () => o.next(true));
});
}
} |