mirror of https://github.com/embarklabs/embark.git
fix swarm spawn
This commit is contained in:
parent
c86c50fb4e
commit
d06a7f43ac
|
@ -1,6 +1,7 @@
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
const ProcessWrapper = require('../../process/processWrapper');
|
const ProcessWrapper = require('../../process/processWrapper');
|
||||||
const constants = require('../../constants');
|
const constants = require('../../constants');
|
||||||
|
const fs = require('../../core/fs');
|
||||||
|
|
||||||
let swarmProcess;
|
let swarmProcess;
|
||||||
|
|
||||||
|
@ -20,15 +21,27 @@ 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 = child_process.spawn(this.storageConfig.swarmPath || 'swarm',
|
|
||||||
[
|
const args = [
|
||||||
`--bzzaccount ${this.storageConfig.account.address}`,
|
`--bzzaccount=${this.storageConfig.account.address}`,
|
||||||
`--password ${this.storageConfig.account.password}`,
|
`--password=${fs.dappPath(this.storageConfig.account.password)}`,
|
||||||
`--corsdomain ${corsDomain}`,
|
`--corsdomain=${corsDomain}`,
|
||||||
"--ens-api ''"
|
`--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;
|
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) => {
|
child.stderr.on('data', (data) => {
|
||||||
|
data = data.toString();
|
||||||
if (!self.readyCalled && data.indexOf('Swarm http proxy started') > -1) {
|
if (!self.readyCalled && data.indexOf('Swarm http proxy started') > -1) {
|
||||||
self.readyCalled = true;
|
self.readyCalled = true;
|
||||||
self.send({result: constants.storage.initiated});
|
self.send({result: constants.storage.initiated});
|
||||||
|
@ -39,7 +52,9 @@ class SwarmProcess extends ProcessWrapper {
|
||||||
child.on('exit', (code) => {
|
child.on('exit', (code) => {
|
||||||
if (code) {
|
if (code) {
|
||||||
console.error('Swarm exited with error code ' + code);
|
console.error('Swarm exited with error code ' + code);
|
||||||
console.error(lastMessage);
|
if (lastMessage) {
|
||||||
|
console.error(lastMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue