boot swarm with spawn

This commit is contained in:
Jonathan Rainville 2018-05-28 12:54:06 -04:00
parent 8655b49a39
commit c86c50fb4e
1 changed files with 8 additions and 11 deletions

View File

@ -1,4 +1,4 @@
const shelljs = require('shelljs'); const child_process = require('child_process');
const ProcessWrapper = require('../../process/processWrapper'); const ProcessWrapper = require('../../process/processWrapper');
const constants = require('../../constants'); const constants = require('../../constants');
@ -20,16 +20,13 @@ class SwarmProcess extends ProcessWrapper {
if (self.webServerConfig && self.webServerConfig && self.webServerConfig.host && self.webServerConfig.port) { if (self.webServerConfig && self.webServerConfig && self.webServerConfig.host && self.webServerConfig.port) {
corsDomain = `http://${self.webServerConfig.host}:${self.webServerConfig.port}`; corsDomain = `http://${self.webServerConfig.host}:${self.webServerConfig.port}`;
} }
const child = shelljs.exec( const child = child_process.spawn(this.storageConfig.swarmPath || 'swarm',
`${this.storageConfig.swarmPath || 'swarm'} --bzzaccount ${this.storageConfig.account.address} --password ${this.storageConfig.account.password} --corsdomain ${corsDomain} --ens-api ''`, [
{silent: true}, (err, _stdout, _stderr) => `--bzzaccount ${this.storageConfig.account.address}`,
{ `--password ${this.storageConfig.account.password}`,
if (err) { `--corsdomain ${corsDomain}`,
console.error(err); "--ens-api ''"
process.exit(1); ]);
}
process.exit();
});
let lastMessage; let lastMessage;
child.stderr.on('data', (data) => { child.stderr.on('data', (data) => {
if (!self.readyCalled && data.indexOf('Swarm http proxy started') > -1) { if (!self.readyCalled && data.indexOf('Swarm http proxy started') > -1) {