feat: unregister plugin on exit

This commit is contained in:
Rainer Killinger
2021-10-04 16:42:31 +02:00
parent f8c3b29c60
commit d083105d6d

View File

@@ -68,3 +68,15 @@ pluginClient.registerPlugin(plugin)
.catch((err: Error) => {
throw err;
});
[`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach((signal) => {
process.once(signal as NodeJS.Signals, () => {
pluginClient.unregisterPlugin(plugin)
.then(() => {
Logger.ok(`Successfully unregistered plugin '${options.pluginName}' from /${options.routeName} .`);
})
.catch((err: Error) => {
throw err;
});
}) ;
});