flocore-node/lib/cli/daemon.js
Braydon Fuller e046f7294e Changes to be able to run with only a configuration file.
- Adds parameter to cli methods to be able to specify the location of services modules. This is useful for packages that wrap bitcore-node to be able to pass along a node_modules directory with services.
- Adds another parameter for including additional services in the default settings.
- Will use the `process.env.HOME + '/.bitcore` as the default configuration location.
- There are now two `getDefaultConfig`, one that will instatiate a `~/.bitcore` directory with a default if it doesn't exist, and `getBaseDefaultConfig` that will return a basic configuration without additional services enabled.
- Changes logic to use the global install if a local node_modules version is not available, this would previously assume that it was a local install because of the existence of a configuration file.
2015-10-20 12:33:53 -04:00

42 lines
1.1 KiB
JavaScript

'use strict';
var program = require('commander');
var path = require('path');
var bitcore = require('..');
function main(servicesPath, additionalServices) {
/* jshint maxstatements: 100 */
var version = bitcore.version;
var start = bitcore.scaffold.start;
var findConfig = bitcore.scaffold.findConfig;
var defaultConfig = bitcore.scaffold.defaultConfig;
program
.version(version)
.description('Start the current node')
.option('-c, --config <dir>', 'Specify the directory with Bitcore Node configuration')
.option('-d, --daemon', 'Make bitcore a daemon (running in the background)');
program.parse(process.argv);
if (program.config) {
program.config = path.resolve(process.cwd(), program.config);
}
var configInfo = findConfig(program.config || process.cwd());
if (!configInfo) {
configInfo = defaultConfig({
additionalServices: additionalServices
});
}
if(program.daemon) {
configInfo.config.daemon = true;
}
if (servicesPath) {
configInfo.servicesPath = servicesPath;
}
start(configInfo);
}
module.exports = main;