ffbt
Version:
Build a Typescript app without pain
18 lines (17 loc) • 563 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cleanupIfError = void 0;
function cleanupIfError(cleanupCallback) {
const endSignals = ["SIGINT", "SIGTERM", "SIGUSR1", "SIGUSR2"];
endSignals.forEach((sig) => {
process.on(sig, () => {
cleanupCallback();
});
});
process.on("uncaughtException", (error) => {
console.log("Process stopped because of uncaught exception");
console.log(error);
cleanupCallback();
});
}
exports.cleanupIfError = cleanupIfError;