embark-area-51/lib/modules/ipfs/ipfsProcess.js

31 lines
689 B
JavaScript
Raw Normal View History

2018-05-28 15:48:27 +00:00
const shelljs = require('shelljs');
const ProcessWrapper = require('../../process/processWrapper');
const constants = require('../../constants');
let ipfsProcess;
class IPFSProcess extends ProcessWrapper {
constructor(_options) {
super();
this.startIPFSDaemon();
}
startIPFSDaemon() {
shelljs.exec('ipfs daemon', (err, _stdout, _stderr) => {
if (err) {
console.error(err);
process.exit(1);
}
process.exit();
});
}
}
process.on('message', (msg) => {
if (msg.action === constants.blockchain.init) {
ipfsProcess = new IPFSProcess(msg.options);
return ipfsProcess.send({result: constants.blockchain.initiated});
}
});