aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/webTorrentNode.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/webTorrentNode.js')
-rw-r--r--src/webTorrentNode.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/webTorrentNode.js b/src/webTorrentNode.js
index ebe8d5d81..507cf31fc 100644
--- a/src/webTorrentNode.js
+++ b/src/webTorrentNode.js
@@ -43,11 +43,23 @@
43 ipc.serve(function () { 43 ipc.serve(function () {
44 if (!webtorrentnode.silent) logger.info('IPC server ready.') 44 if (!webtorrentnode.silent) logger.info('IPC server ready.')
45 45
46 // Run a timeout of 30s after which we exit the process
47 var timeout_webtorrent_process = setTimeout(function () {
48 logger.error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.')
49 process.exit()
50 }, 30000)
51
46 ipc.server.on(processKey + '.ready', function () { 52 ipc.server.on(processKey + '.ready', function () {
47 if (!webtorrentnode.silent) logger.info('Webtorrent process ready.') 53 if (!webtorrentnode.silent) logger.info('Webtorrent process ready.')
54 clearTimeout(timeout_webtorrent_process)
48 callback() 55 callback()
49 }) 56 })
50 57
58 ipc.server.on(processKey + '.exception', function (data) {
59 logger.error('Received exception error from webtorrent process.', { exception: data.exception })
60 process.exit()
61 })
62
51 var webtorrent_process = spawn(__dirname + '/webtorrent.js', host, port, { detached: true }) 63 var webtorrent_process = spawn(__dirname + '/webtorrent.js', host, port, { detached: true })
52 webtorrent_process.stderr.on('data', function (data) { 64 webtorrent_process.stderr.on('data', function (data) {
53 // logger.debug('Webtorrent process stderr: ', data.toString()) 65 // logger.debug('Webtorrent process stderr: ', data.toString())
@@ -57,15 +69,6 @@
57 // logger.debug('Webtorrent process:', data.toString()) 69 // logger.debug('Webtorrent process:', data.toString())
58 }) 70 })
59 71
60 function exitChildProcess () {
61 if (!webtorrentnode.silent) logger.info('Gracefully exit child')
62 process.kill(-webtorrent_process.pid)
63 process.exit(0)
64 }
65
66 process.on('SIGINT', exitChildProcess)
67 process.on('SIGTERM', exitChildProcess)
68
69 webtorrentnode.app = webtorrent_process 72 webtorrentnode.app = webtorrent_process
70 }) 73 })
71 74