]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server.js
add robustness when we run the electron process and move the exit
[github/Chocobozzz/PeerTube.git] / server.js
index fe0cb237addeb15951ed196ec40afcd8242e91e5..96c493f29d9ba9eaae6c1751d1704519c8e0af5f 100644 (file)
--- a/server.js
+++ b/server.js
     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 () {