diff --git a/src/lib/Server.js b/src/lib/Server.js index f8f380bd..19b39a33 100644 --- a/src/lib/Server.js +++ b/src/lib/Server.js @@ -138,6 +138,16 @@ module.exports = class Server { .listen(PORT, () => { debug(`Listening on http://0.0.0.0:${PORT}`); }); + + process.on('SIGTERM', async () => { + debug('SIGTERM signal received: exiting') + Util.exec('wg-quick down wg0').then(() => { + debug('cleaned up wireguard'); + }); + this.app.close(() => { + debug('HTTP server closed') + }) + }) } };