From 7a754ac97f7d788204fbd414cbd7eefd37497be1 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 28 May 2018 15:43:27 -0400 Subject: [PATCH] add more error management to ipfs --- lib/processes/storageProcesses/ipfs.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/processes/storageProcesses/ipfs.js b/lib/processes/storageProcesses/ipfs.js index 8093584e..f50cdc42 100644 --- a/lib/processes/storageProcesses/ipfs.js +++ b/lib/processes/storageProcesses/ipfs.js @@ -33,7 +33,17 @@ class IPFSProcess extends ProcessWrapper { const self = this; const child = child_process.spawn('ipfs', ['daemon']); let lastMessage; + + child.on('error', (err) => { + err = err.toString(); + console.error('IPFS error: ', err); + }); + child.stderr.on('data', (data) => { + data = data.toString(); + console.log(`IPFS error: ${data}`); + }); child.stdout.on('data', (data) => { + data = data.toString(); if (!self.readyCalled && data.indexOf('Daemon is ready') > -1) { self.readyCalled = true; self.send({result: constants.storage.initiated}); @@ -44,7 +54,9 @@ class IPFSProcess extends ProcessWrapper { child.on('exit', (code) => { if (code) { console.error('IPFS exited with error code ' + code); - console.error(lastMessage); + if (lastMessage) { + console.error(lastMessage); + } } }); }