mirror of https://github.com/embarklabs/embark.git
start storage node on run too
This commit is contained in:
parent
fd9da44792
commit
460c2e98f1
|
@ -138,6 +138,7 @@
|
||||||
"Starting ipfs process": "Starting ipfs process",
|
"Starting ipfs process": "Starting ipfs process",
|
||||||
"Storage process for ipfs ended before the end of this process. Code: 0": "Storage process for ipfs ended before the end of this process. Code: 0",
|
"Storage process for ipfs ended before the end of this process. Code: 0": "Storage process for ipfs ended before the end of this process. Code: 0",
|
||||||
"successfully uploaded to swarm": "successfully uploaded to swarm",
|
"successfully uploaded to swarm": "successfully uploaded to swarm",
|
||||||
|
"ipfs process started": "ipfs process started",
|
||||||
"WARNING! DApp path length is too long: ": "WARNING! DApp path length is too long: ",
|
"WARNING! DApp path length is too long: ": "WARNING! DApp path length is too long: ",
|
||||||
"This is known to cause issues with starting geth, please consider reducing your DApp path's length to 66 characters or less.": "This is known to cause issues with starting geth, please consider reducing your DApp path's length to 66 characters or less.",
|
"This is known to cause issues with starting geth, please consider reducing your DApp path's length to 66 characters or less.": "This is known to cause issues with starting geth, please consider reducing your DApp path's length to 66 characters or less.",
|
||||||
"Installing packages...": "Installing packages...",
|
"Installing packages...": "Installing packages...",
|
||||||
|
|
87
lib/index.js
87
lib/index.js
|
@ -1,6 +1,7 @@
|
||||||
let async = require('async');
|
let async = require('async');
|
||||||
const constants = require('./constants');
|
const constants = require('./constants');
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
const StorageProcessesLauncher = require('./processes/storageProcesses/storageProcessesLauncher');
|
||||||
// require("./utils/debug_util.js")(__filename, async);
|
// require("./utils/debug_util.js")(__filename, async);
|
||||||
|
|
||||||
require('colors');
|
require('colors');
|
||||||
|
@ -66,6 +67,41 @@ class Embark {
|
||||||
templateGenerator.generate(destinationFolder, name);
|
templateGenerator.generate(destinationFolder, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_checkStorageEndpoint(engine, platform, callback) {
|
||||||
|
let checkFn;
|
||||||
|
_.find(engine.servicesMonitor.checkList, (value, key) => {
|
||||||
|
if(key.toLowerCase() === platform.toLowerCase()){
|
||||||
|
checkFn = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!checkFn || typeof checkFn.fn !== 'function') {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
checkFn.fn(function (serviceCheckResult) {
|
||||||
|
if (!serviceCheckResult.status || serviceCheckResult.status === 'off') {
|
||||||
|
return callback('No node');
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_startStorageNode(engine, platform, callback) {
|
||||||
|
const storageProcessesLauncher = new StorageProcessesLauncher({
|
||||||
|
logger: engine.logger,
|
||||||
|
events: engine.events,
|
||||||
|
storageConfig: engine.config.storageConfig
|
||||||
|
});
|
||||||
|
return storageProcessesLauncher.launchProcess(platform.toLowerCase(), (err) => {
|
||||||
|
if (err) {
|
||||||
|
engine.logger.error(err);
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
run(options) {
|
run(options) {
|
||||||
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];
|
||||||
|
@ -135,6 +171,19 @@ class Embark {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check storage
|
||||||
|
const platform = engine.config.storageConfig.provider;
|
||||||
|
self._checkStorageEndpoint(engine, platform, (err) => {
|
||||||
|
if (err) {
|
||||||
|
return self._startStorageNode(engine, platform, (err) => {
|
||||||
|
if (err) {
|
||||||
|
engine.logger.error('Error while starting a storage process for ' + platform);
|
||||||
|
engine.logger.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
engine.events.on('outputDone', function () {
|
engine.events.on('outputDone', function () {
|
||||||
engine.logger.info((__("Looking for documentation? You can find it at") + " ").cyan + "http://embark.status.im/docs/".green.underline + ".".cyan);
|
engine.logger.info((__("Looking for documentation? You can find it at") + " ").cyan + "http://embark.status.im/docs/".green.underline + ".".cyan);
|
||||||
engine.logger.info(__("Ready").underline);
|
engine.logger.info(__("Ready").underline);
|
||||||
|
@ -285,8 +334,7 @@ class Embark {
|
||||||
}
|
}
|
||||||
|
|
||||||
upload(options) {
|
upload(options) {
|
||||||
const StorageProcessesLauncher = require('./processes/storageProcesses/storageProcessesLauncher');
|
const self = this;
|
||||||
|
|
||||||
this.context = options.context || [constants.contexts.upload, constants.contexts.build];
|
this.context = options.context || [constants.contexts.upload, constants.contexts.build];
|
||||||
|
|
||||||
let engine = new Engine({
|
let engine = new Engine({
|
||||||
|
@ -325,43 +373,20 @@ class Embark {
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
function checkStorageService(callback){
|
function checkStorageService(callback){
|
||||||
let checkFn;
|
|
||||||
_.find(engine.servicesMonitor.checkList, (value, key) => {
|
|
||||||
if(key.toLowerCase() === platform.toLowerCase()){
|
|
||||||
checkFn = value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!checkFn || typeof checkFn.fn !== 'function') {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
const erroObj = {message: __('Cannot upload: {{platform}} node is not running on {{protocol}}://{{host}}:{{port}}.', {platform: platform, protocol: engine.config.storageConfig.protocol, host: engine.config.storageConfig.host, port: engine.config.storageConfig.port})};
|
const errorObj = {message: __('Cannot upload: {{platform}} node is not running on {{protocol}}://{{host}}:{{port}}.', {platform: platform, protocol: engine.config.storageConfig.protocol, host: engine.config.storageConfig.host, port: engine.config.storageConfig.port})};
|
||||||
function checkEndpoint(cb) {
|
|
||||||
checkFn.fn(function (serviceCheckResult) {
|
|
||||||
if (!serviceCheckResult.status || serviceCheckResult.status === 'off') {
|
|
||||||
return cb(erroObj);
|
|
||||||
}
|
|
||||||
cb();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEndpoint(function (err) {
|
self._checkStorageEndpoint(engine, platform, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
const storageProcessesLauncher = new StorageProcessesLauncher({
|
return self._startStorageNode(engine, platform, (err) => {
|
||||||
logger: engine.logger,
|
|
||||||
events: engine.events,
|
|
||||||
storageConfig: engine.config.storageConfig
|
|
||||||
});
|
|
||||||
return storageProcessesLauncher.launchProcess(platform.toLowerCase(), (err) => {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
engine.logger.error(err);
|
engine.logger.error(err);
|
||||||
return callback(erroObj);
|
return callback(errorObj);
|
||||||
}
|
}
|
||||||
// Check endpoint again to see if really did start
|
// Check endpoint again to see if really did start
|
||||||
checkEndpoint((err) => {
|
self._checkStorageEndpoint(engine, platform, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(errorObj);
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue