fix swarm spawn
This commit is contained in:
parent
7a05a9ac79
commit
9338b6e37f
|
@ -1,6 +1,7 @@
|
|||
const child_process = require('child_process');
|
||||
const ProcessWrapper = require('../../process/processWrapper');
|
||||
const constants = require('../../constants');
|
||||
const fs = require('../../core/fs');
|
||||
|
||||
let swarmProcess;
|
||||
|
||||
|
@ -20,15 +21,27 @@ class SwarmProcess extends ProcessWrapper {
|
|||
if (self.webServerConfig && self.webServerConfig && self.webServerConfig.host && self.webServerConfig.port) {
|
||||
corsDomain = `http://${self.webServerConfig.host}:${self.webServerConfig.port}`;
|
||||
}
|
||||
const child = child_process.spawn(this.storageConfig.swarmPath || 'swarm',
|
||||
[
|
||||
`--bzzaccount ${this.storageConfig.account.address}`,
|
||||
`--password ${this.storageConfig.account.password}`,
|
||||
`--corsdomain ${corsDomain}`,
|
||||
"--ens-api ''"
|
||||
]);
|
||||
|
||||
const args = [
|
||||
`--bzzaccount=${this.storageConfig.account.address}`,
|
||||
`--password=${fs.dappPath(this.storageConfig.account.password)}`,
|
||||
`--corsdomain=${corsDomain}`,
|
||||
`--ens-api=''`
|
||||
];
|
||||
const child = child_process.spawn(this.storageConfig.swarmPath || 'swarm', args, {shell: true});
|
||||
|
||||
child.on('error', (err) => {
|
||||
err = err.toString();
|
||||
console.error('Swarm error: ', err);
|
||||
});
|
||||
let lastMessage;
|
||||
child.stdout.on('data', (data) => {
|
||||
data = data.toString();
|
||||
console.log(`Swarm error: ${data}`);
|
||||
});
|
||||
// Geth logs appear in stderr somehow
|
||||
child.stderr.on('data', (data) => {
|
||||
data = data.toString();
|
||||
if (!self.readyCalled && data.indexOf('Swarm http proxy started') > -1) {
|
||||
self.readyCalled = true;
|
||||
self.send({result: constants.storage.initiated});
|
||||
|
@ -39,7 +52,9 @@ class SwarmProcess extends ProcessWrapper {
|
|||
child.on('exit', (code) => {
|
||||
if (code) {
|
||||
console.error('Swarm exited with error code ' + code);
|
||||
console.error(lastMessage);
|
||||
if (lastMessage) {
|
||||
console.error(lastMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue