mirror of https://github.com/embarklabs/embark.git
adds dashboard logging for: geth, ipfs, swarm
This commit is contained in:
parent
960cd0f792
commit
51b2cce0ea
|
@ -52,6 +52,14 @@ class BlockchainProcessLauncher {
|
||||||
this.blockchainProcess.kill();
|
this.blockchainProcess.kill();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.events.on('logs:ethereum:enable', () => {
|
||||||
|
this.blockchainProcess.silent = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.events.on('logs:ethereum:disable', () => {
|
||||||
|
this.blockchainProcess.silent = true;
|
||||||
|
});
|
||||||
|
|
||||||
this.events.on('exit', () => {
|
this.events.on('exit', () => {
|
||||||
this.blockchainProcess.send('exit');
|
this.blockchainProcess.send('exit');
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,6 +24,8 @@ class BlockchainModule {
|
||||||
self.assertNodeConnection(true, (connected) => {
|
self.assertNodeConnection(true, (connected) => {
|
||||||
if (connected) return cb();
|
if (connected) return cb();
|
||||||
self.startBlockchainNode(cb);
|
self.startBlockchainNode(cb);
|
||||||
|
this.listenToCommands();
|
||||||
|
this.registerConsoleCommands();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,6 +35,35 @@ class BlockchainModule {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listenToCommands() {
|
||||||
|
this.events.setCommandHandler('logs:ethereum:turnOn', (cb) => {
|
||||||
|
this.events.emit('logs:ethereum:enable');
|
||||||
|
return cb(null, 'Enabling Geth logs');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.events.setCommandHandler('logs:ethereum:turnOff', (cb) => {
|
||||||
|
this.events.emit('logs:ethereum:disable');
|
||||||
|
return cb(null, 'Disabling Geth logs');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
registerConsoleCommands() {
|
||||||
|
const self = this;
|
||||||
|
self.embark.registerConsoleCommand((cmd, _options) => {
|
||||||
|
return {
|
||||||
|
match: () => cmd === 'log geth on',
|
||||||
|
process: (cb) => self.events.request('logs:ethereum:turnOn', cb)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
self.embark.registerConsoleCommand((cmd, _options) => {
|
||||||
|
return {
|
||||||
|
match: () => cmd === 'log geth off',
|
||||||
|
process: (cb) => self.events.request('logs:ethereum:turnOff', cb)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
assertNodeConnection(noLogs, cb) {
|
assertNodeConnection(noLogs, cb) {
|
||||||
if (typeof noLogs === 'function') {
|
if (typeof noLogs === 'function') {
|
||||||
cb = noLogs;
|
cb = noLogs;
|
||||||
|
|
|
@ -31,6 +31,8 @@ class IPFS {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.logger.info("IPFS node not found, attempting to start own node");
|
self.logger.info("IPFS node not found, attempting to start own node");
|
||||||
|
this.listenToCommands();
|
||||||
|
this.registerConsoleCommands();
|
||||||
self.startProcess(() => {});
|
self.startProcess(() => {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -133,6 +135,35 @@ class IPFS {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listenToCommands() {
|
||||||
|
this.events.setCommandHandler('logs:ipfs:turnOn', (cb) => {
|
||||||
|
this.events.emit('logs:storage:enable');
|
||||||
|
return cb(null, 'Enabling IPFS logs');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.events.setCommandHandler('logs:ipfs:turnOff', (cb) => {
|
||||||
|
this.events.emit('logs:storage:disable');
|
||||||
|
return cb(null, 'Disabling IPFS logs');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
registerConsoleCommands() {
|
||||||
|
const self = this;
|
||||||
|
self.embark.registerConsoleCommand((cmd, _options) => {
|
||||||
|
return {
|
||||||
|
match: () => cmd === 'log ipfs on',
|
||||||
|
process: (cb) => self.events.request('logs:ipfs:turnOn', cb)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
self.embark.registerConsoleCommand((cmd, _options) => {
|
||||||
|
return {
|
||||||
|
match: () => cmd === 'log ipfs off',
|
||||||
|
process: (cb) => self.events.request('logs:ipfs:turnOff', cb)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
isIpfsStorageEnabledInTheConfig() {
|
isIpfsStorageEnabledInTheConfig() {
|
||||||
let {enabled, available_providers, dappConnection} = this.storageConfig;
|
let {enabled, available_providers, dappConnection} = this.storageConfig;
|
||||||
return enabled && (available_providers.indexOf('ipfs') > 0 || dappConnection.find(c => c.provider === 'ipfs'));
|
return enabled && (available_providers.indexOf('ipfs') > 0 || dappConnection.find(c => c.provider === 'ipfs'));
|
||||||
|
|
|
@ -126,6 +126,15 @@ class StorageProcessesLauncher {
|
||||||
self.logger.info(__(`${storageName} process started`).cyan);
|
self.logger.info(__(`${storageName} process started`).cyan);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.events.on('logs:swarm:enable', () => {
|
||||||
|
self.processes[storageName].silent = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
self.events.on('logs:swarm:disable', () => {
|
||||||
|
self.processes[storageName].silent = true;
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,8 @@ class Swarm {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.logger.info("SWARM: Swarm node not found, attempting to start own node");
|
this.logger.info("SWARM: Swarm node not found, attempting to start own node");
|
||||||
|
this.listenToCommands();
|
||||||
|
this.registerConsoleCommands();
|
||||||
return this.startProcess(() => {});
|
return this.startProcess(() => {});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -116,6 +118,35 @@ class Swarm {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listenToCommands() {
|
||||||
|
this.events.setCommandHandler('logs:swarm:turnOn', (cb) => {
|
||||||
|
this.events.emit('logs:storage:enable');
|
||||||
|
return cb(null, 'Enabling Swarm logs');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.events.setCommandHandler('logs:swarm:turnOff', (cb) => {
|
||||||
|
this.events.emit('logs:storage:disable');
|
||||||
|
return cb(null, 'Disabling Swarm logs');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
registerConsoleCommands() {
|
||||||
|
const self = this;
|
||||||
|
self.embark.registerConsoleCommand((cmd, _options) => {
|
||||||
|
return {
|
||||||
|
match: () => cmd === 'log swarm on',
|
||||||
|
process: (cb) => self.events.request('logs:swarm:turnOn', cb)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
self.embark.registerConsoleCommand((cmd, _options) => {
|
||||||
|
return {
|
||||||
|
match: () => cmd === 'log swarm off',
|
||||||
|
process: (cb) => self.events.request('logs:swarm:turnOff', cb)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
isSwarmEnabledInTheConfig() {
|
isSwarmEnabledInTheConfig() {
|
||||||
let {enabled, available_providers, dappConnection} = this.storageConfig;
|
let {enabled, available_providers, dappConnection} = this.storageConfig;
|
||||||
return enabled && (available_providers.indexOf('swarm') > 0 || dappConnection.find(c => c.provider === 'swarm'));
|
return enabled && (available_providers.indexOf('swarm') > 0 || dappConnection.find(c => c.provider === 'swarm'));
|
||||||
|
|
Loading…
Reference in New Issue