diff --git a/src/cli.ts b/src/cli.ts index db4d02c7..5498bb8c 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -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; + }); + }) ; +});