Fixing shutdowns

This commit is contained in:
Martin Karkowski 2021-05-13 13:26:45 +02:00
parent 9062e9b0d1
commit 995b15e942

View File

@ -2,7 +2,7 @@
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2020-11-11 13:27:58
* @modify date 2021-04-09 08:34:41
* @modify date 2021-05-13 11:30:38
* @desc [description]
*
* TODO: fix imports and make extra function to load communication-bridge.
@ -223,6 +223,17 @@ export async function runNopeBackend(
}
}
const _dispose = () => {
// We should close the Process:
logger.warn("received 'ctrl+c'. Shutting down the Instances");
loader.dispatcher.dispose().finally(process.exit);
};
process.on("SIGINT", _dispose);
process.on("SIGTERM", _dispose);
process.on("exit", () => {
logger.info("Completed. Goodbye");
});
return loader.dispatcher;
}