Merge pull request #473 from embark-framework/refactor_contracts_part3

Refactor contracts part3
This commit is contained in:
Iuri Matias 2018-06-01 19:55:47 -04:00 committed by GitHub
commit 2c34477e67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 113 additions and 146 deletions

View File

@ -1,6 +1,4 @@
const program = require('commander'); const program = require('commander');
const promptly = require('promptly');
const utils = require('./utils/utils.js');
const Embark = require('../lib/index'); const Embark = require('../lib/index');
const i18n = require('./i18n/i18n.js'); const i18n = require('./i18n/i18n.js');
let embark = new Embark; let embark = new Embark;
@ -50,6 +48,7 @@ class Cmd {
.action(function (name, options) { .action(function (name, options) {
i18n.setOrDetectLocale(options.locale); i18n.setOrDetectLocale(options.locale);
if (name === undefined) { if (name === undefined) {
const promptly = require('promptly');
return promptly.prompt(__("Name your app (default is %s):", 'embarkDapp'), { return promptly.prompt(__("Name your app (default is %s):", 'embarkDapp'), {
default: "embarkDApp", default: "embarkDApp",
validator: validateName validator: validateName
@ -259,6 +258,7 @@ class Cmd {
program program
.action(function (cmd) { .action(function (cmd) {
console.log((__('unknown command') + ' "%s"').red, cmd); console.log((__('unknown command') + ' "%s"').red, cmd);
let utils = require('./utils/utils.js');
let dictionary = ['new', 'demo', 'build', 'run', 'blockchain', 'simulator', 'test', 'upload', 'version']; let dictionary = ['new', 'demo', 'build', 'run', 'blockchain', 'simulator', 'test', 'upload', 'version'];
let suggestion = utils.proposeAlternative(cmd, dictionary); let suggestion = utils.proposeAlternative(cmd, dictionary);
if (suggestion) { if (suggestion) {

View File

@ -18,7 +18,6 @@ class Blockchain {
this.web3 = options.web3; this.web3 = options.web3;
this.locale = options.locale; this.locale = options.locale;
this.isDev = options.isDev; this.isDev = options.isDev;
this.addCheck = options.addCheck;
this.web3Endpoint = ''; this.web3Endpoint = '';
this.isWeb3Ready = false; this.isWeb3Ready = false;
this.web3StartedInProcess = false; this.web3StartedInProcess = false;
@ -111,7 +110,7 @@ class Blockchain {
const self = this; const self = this;
const NO_NODE = 'noNode'; const NO_NODE = 'noNode';
this.addCheck('Ethereum', function (cb) { this.events.request("services:register", 'Ethereum', function (cb) {
async.waterfall([ async.waterfall([
function checkNodeConnection(next) { function checkNodeConnection(next) {
self.assertNodeConnection(true, (err) => { self.assertNodeConnection(true, (err) => {

View File

@ -32,7 +32,6 @@ class Engine {
} }
init(_options) { init(_options) {
let self = this;
let options = _options || {}; let options = _options || {};
this.events = options.events || this.events || new Events(); this.events = options.events || this.events || new Events();
this.logger = options.logger || new Logger({logLevel: options.logLevel || this.logLevel || 'debug', events: this.events, logFile: this.logFile}); this.logger = options.logger || new Logger({logLevel: options.logLevel || this.logLevel || 'debug', events: this.events, logFile: this.logFile});
@ -40,11 +39,6 @@ class Engine {
this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs}); this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs});
this.plugins = this.config.plugins; this.plugins = this.config.plugins;
this.servicesMonitor = new ServicesMonitor({events: this.events, logger: this.logger});
this.servicesMonitor.addCheck('embarkVersion', function (cb) {
return cb({name: 'Embark ' + self.version, status: 'on'});
}, 0);
if (this.interceptLogs || this.interceptLogs === undefined) { if (this.interceptLogs || this.interceptLogs === undefined) {
this.doInterceptLogs(); this.doInterceptLogs();
} }
@ -76,22 +70,6 @@ class Engine {
}; };
} }
startMonitor() {
let self = this;
if (this.plugins) {
// --------
// TODO: this only works for services done on startup
// --------
let servicePlugins = this.plugins.getPluginsFor('serviceChecks');
servicePlugins.forEach(function (plugin) {
plugin.serviceChecks.forEach(function (pluginCheck) {
self.servicesMonitor.addCheck(pluginCheck.checkName, pluginCheck.checkFn, pluginCheck.time);
});
});
}
this.servicesMonitor.startMonitor();
}
registerModule(moduleName, options) { registerModule(moduleName, options) {
this.plugins.loadInternalPlugin(moduleName, options || {}); this.plugins.loadInternalPlugin(moduleName, options || {});
} }
@ -100,6 +78,7 @@ class Engine {
let options = _options || {}; let options = _options || {};
let services = { let services = {
"serviceMonitor": this.serviceMonitor,
"pipeline": this.pipelineService, "pipeline": this.pipelineService,
"codeRunner": this.codeRunnerService, "codeRunner": this.codeRunnerService,
"codeGenerator": this.codeGeneratorService, "codeGenerator": this.codeGeneratorService,
@ -146,6 +125,15 @@ class Engine {
}); });
} }
serviceMonitor() {
const self = this;
this.servicesMonitor = new ServicesMonitor({events: this.events, logger: this.logger, plugins: this.plugins});
this.servicesMonitor.addCheck('embarkVersion', function (cb) {
return cb({name: 'Embark ' + self.version, status: 'on'});
}, 0);
this.servicesMonitor.startMonitor();
}
namingSystem(_options) { namingSystem(_options) {
this.registerModule('ens'); this.registerModule('ens');
} }
@ -257,9 +245,7 @@ class Engine {
} }
webServerService() { webServerService() {
this.registerModule('webserver', { this.registerModule('webserver');
addCheck: this.servicesMonitor.addCheck.bind(this.servicesMonitor)
});
} }
storageService(_options) { storageService(_options) {
@ -281,7 +267,6 @@ class Engine {
this.blockchain = new Blockchain({ this.blockchain = new Blockchain({
contractsConfig: this.config.contractsConfig, contractsConfig: this.config.contractsConfig,
blockchainConfig: this.config.blockchainConfig, blockchainConfig: this.config.blockchainConfig,
addCheck: this.servicesMonitor.addCheck.bind(this.servicesMonitor),
events: this.events, events: this.events,
logger: this.logger, logger: this.logger,
isDev: this.isDev, isDev: this.isDev,
@ -290,7 +275,6 @@ class Engine {
}); });
this.registerModule('whisper', { this.registerModule('whisper', {
addCheck: this.servicesMonitor.addCheck.bind(this.servicesMonitor),
// TODO: this should not be needed and should be deducted from the config instead // TODO: this should not be needed and should be deducted from the config instead
// the eth provider is not necessary the same as the whisper one // the eth provider is not necessary the same as the whisper one
web3: this.blockchain.web3 web3: this.blockchain.web3

View File

@ -120,52 +120,50 @@ Plugin.prototype.interceptLogs = function(context) {
// TODO: add deploy provider // TODO: add deploy provider
Plugin.prototype.registerClientWeb3Provider = function(cb) { Plugin.prototype.registerClientWeb3Provider = function(cb) {
this.clientWeb3Providers.push(cb); this.clientWeb3Providers.push(cb);
this.pluginTypes.push('clientWeb3Provider'); this.addPluginType('clientWeb3Provider');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.registerContractsGeneration = function(cb) { Plugin.prototype.registerContractsGeneration = function(cb) {
this.contractsGenerators.push(cb); this.contractsGenerators.push(cb);
this.pluginTypes.push('contractGeneration'); this.addPluginType('contractGeneration');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.registerPipeline = function(matcthingFiles, cb) { Plugin.prototype.registerPipeline = function(matcthingFiles, cb) {
// TODO: generate error for more than one pipeline per plugin // TODO: generate error for more than one pipeline per plugin
this.pipeline.push({matcthingFiles: matcthingFiles, cb: cb}); this.pipeline.push({matcthingFiles: matcthingFiles, cb: cb});
this.pluginTypes.push('pipeline'); this.addPluginType('pipeline');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.addFileToPipeline = function(file, intendedPath, options) { Plugin.prototype.addFileToPipeline = function(file, intendedPath, options) {
this.pipelineFiles.push({file: file, intendedPath: intendedPath, options: options}); this.pipelineFiles.push({file: file, intendedPath: intendedPath, options: options});
this.pluginTypes.push('pipelineFiles'); this.addPluginType('pipelineFiles');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.addContractFile = function(file) { Plugin.prototype.addContractFile = function(file) {
this.contractsFiles.push(file); this.contractsFiles.push(file);
this.pluginTypes.push('contractFiles'); this.addPluginType('contractFiles');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.registerConsoleCommand = function(cb) { Plugin.prototype.registerConsoleCommand = function(cb) {
this.console.push(cb); this.console.push(cb);
this.pluginTypes.push('console'); this.addPluginType('console');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
// TODO: this only works for services done on startup // TODO: this only works for services done on startup
Plugin.prototype.registerServiceCheck = function(checkName, checkFn, time) { Plugin.prototype.registerServiceCheck = function(checkName, checkFn, time) {
this.serviceChecks.push({checkName: checkName, checkFn: checkFn, time: time}); this.serviceChecks.push({checkName: checkName, checkFn: checkFn, time: time});
this.pluginTypes.push('serviceChecks'); this.addPluginType('serviceChecks');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.has = function(pluginType) { Plugin.prototype.has = function(pluginType) {
return this.pluginTypes.indexOf(pluginType) >= 0; return this.pluginTypes.indexOf(pluginType) >= 0;
}; };
Plugin.prototype.addPluginType = function(pluginType) {
this.pluginTypes.push(pluginType);
this.pluginTypes = _.uniq(this.pluginTypes);
};
Plugin.prototype.generateProvider = function(args) { Plugin.prototype.generateProvider = function(args) {
return this.clientWeb3Providers.map(function(cb) { return this.clientWeb3Providers.map(function(cb) {
return cb.call(this, args); return cb.call(this, args);
@ -180,39 +178,33 @@ Plugin.prototype.generateContracts = function(args) {
Plugin.prototype.registerContractConfiguration = function(config) { Plugin.prototype.registerContractConfiguration = function(config) {
this.contractsConfigs.push(config); this.contractsConfigs.push(config);
this.pluginTypes.push('contractsConfig'); this.addPluginType('contractsConfig');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.registerCompiler = function(extension, cb) { Plugin.prototype.registerCompiler = function(extension, cb) {
this.compilers.push({extension: extension, cb: cb}); this.compilers.push({extension: extension, cb: cb});
this.pluginTypes.push('compilers'); this.addPluginType('compilers');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.registerUploadCommand = function(cmd, cb) { Plugin.prototype.registerUploadCommand = function(cmd, cb) {
this.uploadCmds.push({cmd: cmd, cb: cb}); this.uploadCmds.push({cmd: cmd, cb: cb});
this.pluginTypes.push('uploadCmds'); this.addPluginType('uploadCmds');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.addCodeToEmbarkJS = function(code) { Plugin.prototype.addCodeToEmbarkJS = function(code) {
this.embarkjs_code.push(code); this.embarkjs_code.push(code);
this.pluginTypes.push('embarkjsCode'); this.addPluginType('embarkjsCode');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.addProviderInit = function(providerType, code, initCondition) { Plugin.prototype.addProviderInit = function(providerType, code, initCondition) {
this.embarkjs_init_code[providerType] = this.embarkjs_init_code[providerType] || []; this.embarkjs_init_code[providerType] = this.embarkjs_init_code[providerType] || [];
this.embarkjs_init_code[providerType].push([code, initCondition]); this.embarkjs_init_code[providerType].push([code, initCondition]);
this.pluginTypes.push('initCode'); this.addPluginType('initCode');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.registerImportFile = function(importName, importLocation) { Plugin.prototype.registerImportFile = function(importName, importLocation) {
this.imports.push([importName, importLocation]); this.imports.push([importName, importLocation]);
this.pluginTypes.push('imports'); this.addPluginType('imports');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.registerActionForEvent = function(eventName, cb) { Plugin.prototype.registerActionForEvent = function(eventName, cb) {
@ -220,8 +212,7 @@ Plugin.prototype.registerActionForEvent = function(eventName, cb) {
this.eventActions[eventName] = []; this.eventActions[eventName] = [];
} }
this.eventActions[eventName].push(cb); this.eventActions[eventName].push(cb);
this.pluginTypes.push('eventActions'); this.addPluginType('eventActions');
this.pluginTypes = _.uniq(this.pluginTypes);
}; };
Plugin.prototype.runFilePipeline = function() { Plugin.prototype.runFilePipeline = function() {

View File

@ -2,12 +2,18 @@ let async = require('../utils/async_extend.js');
class ServicesMonitor { class ServicesMonitor {
constructor(options) { constructor(options) {
const self = this;
this.events = options.events; this.events = options.events;
this.logger = options.logger; this.logger = options.logger;
this.plugins = options.plugins;
this.checkList = {}; this.checkList = {};
this.checkTimers = {}; this.checkTimers = {};
this.checkState = {}; this.checkState = {};
this.working = false; this.working = false;
self.events.setCommandHandler("services:register", (checkName, checkFn, time) => {
self.addCheck(checkName, checkFn, time);
});
} }
} }
@ -65,6 +71,11 @@ ServicesMonitor.prototype.startMonitor = function () {
this.working = true; this.working = true;
this.logger.trace('startMonitor'); this.logger.trace('startMonitor');
let servicePlugins = this.plugins.getPluginsProperty('serviceChecks', 'serviceChecks');
servicePlugins.forEach(function (pluginCheck) {
self.addCheck(pluginCheck.checkName, pluginCheck.checkFn, pluginCheck.time);
});
async.eachObject(this.checkList, function (checkName, check, callback) { async.eachObject(this.checkList, function (checkName, check, callback) {
self.initCheck(checkName); self.initCheck(checkName);
callback(); callback();

View File

@ -1,4 +1,5 @@
let async = require('async'); let async = require('async');
let windowSize = require('window-size');
let Monitor = require('./monitor.js'); let Monitor = require('./monitor.js');
let Console = require('./console.js'); let Console = require('./console.js');
@ -11,6 +12,16 @@ class Dashboard {
this.version = options.version; this.version = options.version;
this.env = options.env; this.env = options.env;
this.contractsConfig = options.contractsConfig; this.contractsConfig = options.contractsConfig;
this.events.on('firstDeploymentDone', this.checkWindowSize.bind(this));
this.events.on('outputDone', this.checkWindowSize.bind(this));
}
checkWindowSize() {
let size = windowSize.get();
if (size.height < 40 || size.width < 118) {
this.logger.warn(__("tip: you can resize the terminal or disable the dashboard with") + " embark run --nodashboard".bold.underline);
}
} }
start(done) { start(done) {

View File

@ -161,5 +161,10 @@
"Cannot upload: {{platform}} node is not running on {{url}}.": "Cannot upload: {{platform}} node is not running on {{url}}.", "Cannot upload: {{platform}} node is not running on {{url}}.": "Cannot upload: {{platform}} node is not running on {{url}}.",
"Cannot start {{platform}} node on {{url}}.": "Cannot start {{platform}} node on {{url}}.", "Cannot start {{platform}} node on {{url}}.": "Cannot start {{platform}} node on {{url}}.",
"Storage process for swarm ended before the end of this process. Code: 0": "Storage process for swarm ended before the end of this process. Code: 0", "Storage process for swarm ended before the end of this process. Code: 0": "Storage process for swarm ended before the end of this process. Code: 0",
"error uploading to swarm": "error uploading to swarm" "error uploading to swarm": "error uploading to swarm",
"IPFS node detected": "IPFS node detected",
"Ethereum node detected": "Ethereum node detected",
"Starting swarm process": "Starting swarm process",
"Deployment Done": "Deployment Done",
"Name your app (default is %s):": "Name your app (default is %s):"
} }

View File

@ -68,7 +68,6 @@ class Embark {
let self = this; let self = this;
self.context = options.context || [constants.contexts.run, constants.contexts.build]; self.context = options.context || [constants.contexts.run, constants.contexts.build];
let Dashboard = require('./dashboard/dashboard.js'); let Dashboard = require('./dashboard/dashboard.js');
let windowSize = require('window-size');
let engine = new Engine({ let engine = new Engine({
env: options.env, env: options.env,
@ -114,7 +113,7 @@ class Embark {
engine.logger.info(__("loaded plugins") + ": " + pluginList.join(", ")); engine.logger.info(__("loaded plugins") + ": " + pluginList.join(", "));
} }
engine.startMonitor(); engine.startService("serviceMonitor");
engine.startService("libraryManager"); engine.startService("libraryManager");
engine.startService("codeRunner"); engine.startService("codeRunner");
engine.startService("web3"); engine.startService("web3");
@ -153,11 +152,6 @@ class Embark {
engine.logger.info(err.stack); engine.logger.info(err.stack);
} else { } else {
engine.events.emit('firstDeploymentDone'); engine.events.emit('firstDeploymentDone');
let size = windowSize.get();
if (size.height < 40 || size.width < 118) {
engine.logger.warn(__("tip: you can resize the terminal or disable the dashboard with") + " embark run --nodashboard".bold.underline);
}
} }
}); });
} }
@ -238,7 +232,7 @@ class Embark {
engine.logger.info(__("loaded plugins") + ": " + pluginList.join(", ")); engine.logger.info(__("loaded plugins") + ": " + pluginList.join(", "));
} }
engine.startMonitor(); engine.startService("serviceMonitor");
engine.startService("libraryManager"); engine.startService("libraryManager");
engine.startService("pipeline"); engine.startService("pipeline");
engine.startService("deployment", {onlyCompile: true}); engine.startService("deployment", {onlyCompile: true});
@ -300,6 +294,7 @@ class Embark {
function startServices(callback) { function startServices(callback) {
engine.startService("serviceMonitor");
engine.startService("libraryManager"); engine.startService("libraryManager");
engine.startService("codeRunner"); engine.startService("codeRunner");
engine.startService("web3"); engine.startService("web3");
@ -307,7 +302,6 @@ class Embark {
engine.startService("deployment"); engine.startService("deployment");
engine.startService("storage"); engine.startService("storage");
engine.startService("codeGenerator"); engine.startService("codeGenerator");
engine.startMonitor();
callback(); callback();
}, },
function setupStoragePlugin(callback){ function setupStoragePlugin(callback){

View File

@ -10,11 +10,10 @@ class IPFS {
this.logger = embark.logger; this.logger = embark.logger;
this.events = embark.events; this.events = embark.events;
this.buildDir = options.buildDir; this.buildDir = options.buildDir;
this.storageConfig = options.storageConfig; this.storageConfig = embark.config.storageConfig;
this.host = options.host || this.storageConfig.upload.host; this.host = options.host || this.storageConfig.upload.host;
this.port = options.port || this.storageConfig.upload.port; this.port = options.port || this.storageConfig.upload.port;
this.protocol = options.protocol || this.storageConfig.upload.protocol; this.protocol = options.protocol || this.storageConfig.upload.protocol;
this.addCheck = options.addCheck;
this.embark = embark; this.embark = embark;
} }
@ -48,11 +47,7 @@ class IPFS {
self.logger.info(__('IPFS node is offline') + '..'); self.logger.info(__('IPFS node is offline') + '..');
}); });
if (!self.addCheck) { self.events.request("services:register", 'IPFS', function (cb) {
return;
}
self.addCheck('IPFS', function (cb) {
self.logger.trace("Checking IPFS version..."); self.logger.trace("Checking IPFS version...");
let url = (self.protocol || 'http') + '://' + self.host + ':' + self.port + '/api/v0/version'; let url = (self.protocol || 'http') + '://' + self.host + ':' + self.port + '/api/v0/version';
if(self.protocol !== 'https'){ if(self.protocol !== 'https'){

View File

@ -7,7 +7,6 @@ class SpecialConfigs {
this.logger = embark.logger; this.logger = embark.logger;
this.events = embark.events; this.events = embark.events;
this.buildDir = options.buildDir; this.buildDir = options.buildDir;
this.addCheck = options.addCheck;
this.embark = embark; this.embark = embark;
this.contractsConfig = embark.config.contractsConfig; this.contractsConfig = embark.config.contractsConfig;

View File

@ -155,59 +155,45 @@ class Storage {
this._embark.addProviderInit('storage', code, shouldInit); this._embark.addProviderInit('storage', code, shouldInit);
} }
checkStorageService(platform, url, callback) {
const self = this;
const errorObj = {message: __('Cannot upload: {{platform}} node is not running on {{url}}.', {platform: platform, url: url})};
// start the upload storage node
self._checkStorageEndpoint(platform, function (err) {
if (!err) {
return callback();
}
self._startStorageNode(platform, (err) => {
if (err) {
self._logger.error(err);
return callback(errorObj);
}
// Check endpoint again to see if really did start
self._checkStorageEndpoint(platform, (err) => {
if (err) {
return callback(errorObj);
}
callback();
});
});
});
}
startStorageProcesses(){ startStorageProcesses(){
let platform = this._storageConfig.upload.provider; let platform = this._storageConfig.upload.provider;
let self = this; let self = this;
async.waterfall([ async.waterfall([
function checkStorageService(callback){ function _checkStorageService(callback){
const errorObj = {message: __('Cannot upload: {{platform}} node is not running on {{url}}.', {platform: platform, url: utils.buildUrlFromConfig(self._storageConfig.upload)})}; self.checkStorageService(platform, utils.buildUrlFromConfig(self._storageConfig.upload), callback);
// start the upload storage node
self._checkStorageEndpoint(platform, function (err) {
if (!err) {
return callback();
}
self._startStorageNode(platform, (err) => {
if (err) {
self._logger.error(err);
return callback(errorObj);
}
// Check endpoint again to see if really did start
self._checkStorageEndpoint(platform, (err) => {
if (err) {
return callback(errorObj);
}
callback();
});
});
});
}, },
function checkDappConnectionStorageService(callback){ function checkDappConnectionStorageService(callback){
// start any dappConnection storage nodes // start any dappConnection storage nodes
self._validDappProviders.forEach(dappConn => { self._validDappProviders.forEach(dappConn => {
if(!dappConn.provider || dappConn.provider === platform) return; // don't start the process we've just started above if(!dappConn.provider || dappConn.provider === platform) return; // don't start the process we've just started above
const errorObj = {message: __('Cannot start {{platform}} node on {{url}}.', {platform: dappConn.provider, url: utils.buildUrlFromConfig(dappConn)})}; self.checkStorageService(dappConn.provider, utils.buildUrlFromConfig(dappConn), callback);
self._checkStorageEndpoint(dappConn.provider, function (err) {
if (!err) {
return callback();
}
self._startStorageNode(dappConn.provider, (err) => {
if (err) {
self._logger.error(err);
return callback(errorObj);
}
// Check endpoint again to see if really did start
self._checkStorageEndpoint(dappConn.provider, (err) => {
if (err) {
return callback(errorObj);
}
callback();
});
});
});
}); });
} }
]); ]);

View File

@ -10,8 +10,9 @@ class Swarm {
this.logger = embark.logger; this.logger = embark.logger;
this.events = embark.events; this.events = embark.events;
this.buildDir = options.buildDir; this.buildDir = options.buildDir;
this.storageConfig = options.storageConfig; this.storageConfig = embark.config.storageConfig;
this.addCheck = options.addCheck; this.host = options.host || this.storageConfig.host;
this.port = options.port || this.storageConfig.port;
this.embark = embark; this.embark = embark;
this.providerUrl = utils.buildUrl(options.protocol || options.storageConfig.upload.protocol, options.host || options.storageConfig.upload.host, options.port || options.storageConfig.upload.port); this.providerUrl = utils.buildUrl(options.protocol || options.storageConfig.upload.protocol, options.host || options.storageConfig.upload.host, options.port || options.storageConfig.upload.port);
@ -32,7 +33,6 @@ class Swarm {
this.embark.registerUploadCommand('swarm', this.upload_swarm.deploy.bind(this.upload_swarm)); this.embark.registerUploadCommand('swarm', this.upload_swarm.deploy.bind(this.upload_swarm));
} }
setServiceCheck() { setServiceCheck() {
let self = this; let self = this;
@ -53,12 +53,7 @@ class Swarm {
self.logger.info(__('Swarm node is offline...')); self.logger.info(__('Swarm node is offline...'));
}); });
if (!this.addCheck) { self.events.request("services:register", 'Swarm', function(cb){
return;
}
// add check for console
this.addCheck('Swarm', function(cb){
self.logger.trace("Checking Swarm availability..."); self.logger.trace("Checking Swarm availability...");
self.bzz.isAvailable().then(result => { self.bzz.isAvailable().then(result => {
return cb({name: "Swarm ", status: result ? 'on':'off'}); return cb({name: "Swarm ", status: result ? 'on':'off'});

View File

@ -7,7 +7,6 @@ class WebServer {
this.embark = embark; this.embark = embark;
this.logger = embark.logger; this.logger = embark.logger;
this.events = embark.events; this.events = embark.events;
this.addCheck = options.addCheck;
this.webServerConfig = embark.config.webServerConfig; this.webServerConfig = embark.config.webServerConfig;
if (!this.webServerConfig.enabled) { if (!this.webServerConfig.enabled) {
return; return;
@ -29,8 +28,7 @@ class WebServer {
setServiceCheck() { setServiceCheck() {
let url = 'http://' + this.host + ':' + this.port; let url = 'http://' + this.host + ':' + this.port;
//embark.registerServiceCheck('WebserverService', function (cb) { this.events.request("services:register", 'Webserver', function (cb) {
this.addCheck('Webserver', function (cb) {
utils.checkIsAvailable(url, function (available) { utils.checkIsAvailable(url, function (available) {
let devServer = __('Webserver') + ' (' + url + ')'; let devServer = __('Webserver') + ' (' + url + ')';
let serverStatus = (available ? 'on' : 'off'); let serverStatus = (available ? 'on' : 'off');

View File

@ -4,11 +4,10 @@ let Web3 = require('web3');
class Whisper { class Whisper {
constructor(embark, options) { constructor(embark, _options) {
this.logger = embark.logger; this.logger = embark.logger;
this.events = embark.events; this.events = embark.events;
this.communicationConfig = embark.config.communicationConfig; this.communicationConfig = embark.config.communicationConfig;
this.addCheck = options.addCheck;
this.web3 = new Web3(); this.web3 = new Web3();
this.embark = embark; this.embark = embark;
@ -26,7 +25,7 @@ class Whisper {
setServiceCheck() { setServiceCheck() {
const self = this; const self = this;
self.addCheck('Whisper', function (cb) { self.events.request("services:register", 'Whisper', function (cb) {
if (!self.web3.currentProvider || self.web3.currentProvider.connection.readyState !== 1) { if (!self.web3.currentProvider || self.web3.currentProvider.connection.readyState !== 1) {
return self.connectToProvider(); return self.connectToProvider();
} }

View File

@ -89,7 +89,7 @@
"dom-helpers": { "dom-helpers": {
"version": "3.3.1", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.3.1.tgz", "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.3.1.tgz",
"integrity": "sha1-/BpOFf/fYN3eA6SAqcD+zoId1KY=" "integrity": "sha512-2Sm+JaYn74OiTM2wHvxJOo3roiq/h25Yi69Fqk269cNUwIXsCvATB6CRSFC9Am/20G2b28hGv/+7NiWydIrPvg=="
}, },
"dotenv": { "dotenv": {
"version": "4.0.0", "version": "4.0.0",
@ -229,7 +229,7 @@
"node-fetch": { "node-fetch": {
"version": "1.7.3", "version": "1.7.3",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
"integrity": "sha1-mA9vcthSEaU0fGsrwYxbhMPrR+8=", "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
"requires": { "requires": {
"encoding": "0.1.12", "encoding": "0.1.12",
"is-stream": "1.1.0" "is-stream": "1.1.0"
@ -252,7 +252,7 @@
"promise": { "promise": {
"version": "7.3.1", "version": "7.3.1",
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
"integrity": "sha1-BktyYCsY+Q8pGSuLG8QY/9Hr078=", "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
"requires": { "requires": {
"asap": "2.0.6" "asap": "2.0.6"
} }
@ -289,7 +289,7 @@
"react-bootstrap": { "react-bootstrap": {
"version": "0.32.1", "version": "0.32.1",
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-0.32.1.tgz", "resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-0.32.1.tgz",
"integrity": "sha1-YGJMG0ijnXc+9szmQhpPM+zBZrs=", "integrity": "sha512-RbfzKUbsukWsToWqGHfCCyMFq9QQI0TznutdyxyJw6dih2NvIne25Mrssg8LZsprqtPpyQi8bN0L0Fx3fUsL8Q==",
"requires": { "requires": {
"babel-runtime": "6.26.0", "babel-runtime": "6.26.0",
"classnames": "2.2.5", "classnames": "2.2.5",
@ -319,7 +319,7 @@
"react-overlays": { "react-overlays": {
"version": "0.8.3", "version": "0.8.3",
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-0.8.3.tgz", "resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-0.8.3.tgz",
"integrity": "sha1-+tZe6lskMBzKGSoWn13dsLINOsU=", "integrity": "sha512-h6GT3jgy90PgctleP39Yu3eK1v9vaJAW73GOA/UbN9dJ7aAN4BTZD6793eI1D5U+ukMk17qiqN/wl3diK1Z5LA==",
"requires": { "requires": {
"classnames": "2.2.5", "classnames": "2.2.5",
"dom-helpers": "3.3.1", "dom-helpers": "3.3.1",
@ -353,7 +353,7 @@
"regenerator-runtime": { "regenerator-runtime": {
"version": "0.11.1", "version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk=" "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
}, },
"setimmediate": { "setimmediate": {
"version": "1.0.5", "version": "1.0.5",
@ -412,7 +412,7 @@
"zeppelin-solidity": { "zeppelin-solidity": {
"version": "1.8.0", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/zeppelin-solidity/-/zeppelin-solidity-1.8.0.tgz", "resolved": "https://registry.npmjs.org/zeppelin-solidity/-/zeppelin-solidity-1.8.0.tgz",
"integrity": "sha1-BJ/N59rqn8hSEPjG25+M0auKhTo=", "integrity": "sha512-7Mxq6Y7EES0PSLrRF6v0EVYqBVRRo8hFrr7m3jEs69VbbQ5kpANzizeEdbP1/PWKSOmBOg208qP2vSA0FlzFLA==",
"requires": { "requires": {
"dotenv": "4.0.0", "dotenv": "4.0.0",
"ethjs-abi": "0.2.1" "ethjs-abi": "0.2.1"