embark-area-51/lib/processes/storageProcesses/ipfs.js

31 lines
699 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', {silent: true}, (err, _stdout, _stderr) => {
2018-05-28 15:48:27 +00:00
if (err) {
console.error(err);
process.exit(1);
}
process.exit();
});
}
}
process.on('message', (msg) => {
if (msg.action === constants.storage.init) {
2018-05-28 15:48:27 +00:00
ipfsProcess = new IPFSProcess(msg.options);
return ipfsProcess.send({result: constants.storage.initiated});
2018-05-28 15:48:27 +00:00
}
});