mirror of https://github.com/embarklabs/embark.git
fix swarm
This commit is contained in:
parent
b5e96beb81
commit
4db2d40ef5
|
@ -37,7 +37,7 @@ class StorageProcessesLauncher {
|
||||||
modulePath: filePath,
|
modulePath: filePath,
|
||||||
logger: self.logger,
|
logger: self.logger,
|
||||||
events: self.events,
|
events: self.events,
|
||||||
silent: true,
|
silent: false,
|
||||||
exitCallback: self.processExited.bind(this, storageName)
|
exitCallback: self.processExited.bind(this, storageName)
|
||||||
});
|
});
|
||||||
self.processes[storageName].send({
|
self.processes[storageName].send({
|
||||||
|
|
|
@ -25,21 +25,20 @@ class SwarmProcess extends ProcessWrapper {
|
||||||
const args = [
|
const args = [
|
||||||
`--bzzaccount=${this.storageConfig.account.address}`,
|
`--bzzaccount=${this.storageConfig.account.address}`,
|
||||||
`--password=${fs.dappPath(this.storageConfig.account.password)}`,
|
`--password=${fs.dappPath(this.storageConfig.account.password)}`,
|
||||||
`--corsdomain=${corsDomain}`,
|
`--corsdomain=${corsDomain}`
|
||||||
`--ens-api=''`
|
|
||||||
];
|
];
|
||||||
const child = child_process.spawn(this.storageConfig.swarmPath || 'swarm', args, {shell: true});
|
this.child = child_process.spawn(this.storageConfig.swarmPath || 'swarm', args);
|
||||||
|
|
||||||
child.on('error', (err) => {
|
this.child.on('error', (err) => {
|
||||||
err = err.toString();
|
err = err.toString();
|
||||||
console.error('Swarm error: ', err);
|
console.error('Swarm error: ', err);
|
||||||
});
|
});
|
||||||
child.stdout.on('data', (data) => {
|
this.child.stdout.on('data', (data) => {
|
||||||
data = data.toString();
|
data = data.toString();
|
||||||
console.log(`Swarm error: ${data}`);
|
console.log(`Swarm error: ${data}`);
|
||||||
});
|
});
|
||||||
// Swarm logs appear in stderr somehow
|
// Swarm logs appear in stderr somehow
|
||||||
child.stderr.on('data', (data) => {
|
this.child.stderr.on('data', (data) => {
|
||||||
data = data.toString();
|
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;
|
||||||
|
@ -47,15 +46,24 @@ class SwarmProcess extends ProcessWrapper {
|
||||||
}
|
}
|
||||||
console.log('Swarm: ' + data);
|
console.log('Swarm: ' + data);
|
||||||
});
|
});
|
||||||
child.on('exit', (code) => {
|
this.child.on('exit', (code) => {
|
||||||
if (code) {
|
if (code) {
|
||||||
console.error('Swarm exited with error code ' + code);
|
console.error('Swarm exited with error code ' + code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kill() {
|
||||||
|
if (this.child) {
|
||||||
|
this.child.kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('message', (msg) => {
|
process.on('message', (msg) => {
|
||||||
|
if (msg === 'exit') {
|
||||||
|
return swarmProcess.kill();
|
||||||
|
}
|
||||||
if (msg.action === constants.storage.init) {
|
if (msg.action === constants.storage.init) {
|
||||||
swarmProcess = new SwarmProcess(msg.options);
|
swarmProcess = new SwarmProcess(msg.options);
|
||||||
const error = swarmProcess.startSwarmDaemon();
|
const error = swarmProcess.startSwarmDaemon();
|
||||||
|
|
Loading…
Reference in New Issue