From 0ae2e7f73c24779f8c99453fb02491382cc0520e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 2 Nov 2015 22:19:39 +0100 Subject: add robustness when we run the electron process and move the exit controller inside the main js file --- server.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'server.js') diff --git a/server.js b/server.js index fe0cb237a..96c493f29 100644 --- a/server.js +++ b/server.js @@ -150,6 +150,18 @@ if (err) throw err // Create/activate the webtorrent module webtorrent.create(function () { + function cleanForExit () { + utils.cleanForExit(webtorrent.app) + } + + function exitGracefullyOnSignal () { + process.exit() + } + + process.on('exit', cleanForExit) + process.on('SIGINT', exitGracefullyOnSignal) + process.on('SIGTERM', exitGracefullyOnSignal) + // ----------- Make the server listening ----------- server.listen(port, function () { videos.seedAll(function () { -- cgit v1.2.3