"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const log_1 = require("@/utils/log");
const child_process_1 = require("@/child-process");
const app_debug_1 = require("./app-debug");
const log = new log_1.Logger('process-handler');
const onExit = (...arg) => {
    child_process_1.killChildProcess();
    log.info('on exit: %j', arg);
    app_debug_1.stopServer(true, ...arg);
};
const onError = (e) => log.error('unhandledRejection %s', e === null || e === void 0 ? void 0 : e.stack);
// 捕获 promise reject
process.on('unhandledRejection', onError);
// 捕获未处理的异常
process.on('uncaughtexception', onError);
// 捕获程序退出
process.on('exit', () => onExit('exit'));
// 捕获 ctrl c
process.on('SIGINT', () => onExit('SIGINT'));
// 捕获 kill
process.on('SIGTERM', () => onExit('SIGTERM'));
