add more error management to ipfs
This commit is contained in:
parent
9338b6e37f
commit
7a754ac97f
|
@ -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,8 +54,10 @@ class IPFSProcess extends ProcessWrapper {
|
|||
child.on('exit', (code) => {
|
||||
if (code) {
|
||||
console.error('IPFS exited with error code ' + code);
|
||||
if (lastMessage) {
|
||||
console.error(lastMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue