2015-06-24 21:45:54 +00:00
|
|
|
#!/usr/bin/env node
|
2015-06-24 21:36:17 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-04-27 02:16:47 +00:00
|
|
|
var cluster = require('cluster');
|
|
|
|
|
|
|
|
if (!cluster.isMaster) {
|
|
|
|
require('../lib/worker.js');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-05 00:27:29 +00:00
|
|
|
var crypto = require('crypto');
|
2017-06-09 17:18:05 +00:00
|
|
|
var PromiseA = require('bluebird');
|
|
|
|
var fs = PromiseA.promisifyAll(require('fs'));
|
|
|
|
var configStorage;
|
|
|
|
function mergeSettings(orig, changes) {
|
|
|
|
Object.keys(changes).forEach(function (key) {
|
|
|
|
// TODO: use an API that can properly handle updating arrays.
|
|
|
|
if (!changes[key] || (typeof changes[key] !== 'object') || Array.isArray(changes[key])) {
|
|
|
|
orig[key] = changes[key];
|
|
|
|
}
|
|
|
|
else if (!orig[key] || typeof orig[key] !== 'object') {
|
|
|
|
orig[key] = changes[key];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mergeSettings(orig[key], changes[key]);
|
|
|
|
}
|
|
|
|
});
|
2017-04-27 02:16:47 +00:00
|
|
|
}
|
2017-10-05 00:27:29 +00:00
|
|
|
|
|
|
|
function fixRawConfig(config) {
|
|
|
|
var updated = false;
|
|
|
|
|
2017-10-12 17:57:43 +00:00
|
|
|
// First converge all of the `bind` properties for protocols that are on top
|
|
|
|
// of TCP to `tcp.bind`.
|
2017-10-11 19:06:24 +00:00
|
|
|
if (config.tcp && config.tcp.bind && !Array.isArray(config.tcp.bind)) {
|
2017-10-11 18:11:20 +00:00
|
|
|
config.tcp.bind = [ config.tcp.bind ];
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
if (config.http && config.http.bind) {
|
|
|
|
config.tcp = config.tcp || { bind: [] };
|
|
|
|
config.tcp.bind = (config.tcp.bind || []).concat(config.http.bind);
|
|
|
|
delete config.http.bind;
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
if (config.tls && config.tls.bind) {
|
|
|
|
config.tcp = config.tcp || { bind: [] };
|
|
|
|
config.tcp.bind = (config.tcp.bind || []).concat(config.tls.bind);
|
|
|
|
delete config.tls.bind;
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
|
2017-10-12 17:57:43 +00:00
|
|
|
// Then we rename dns to udp since the only thing we currently do with those
|
|
|
|
// modules is proxy the packets without inspecting them at all.
|
2017-10-11 18:11:20 +00:00
|
|
|
if (config.dns) {
|
|
|
|
config.udp = config.dns;
|
|
|
|
delete config.dns;
|
|
|
|
updated = true;
|
|
|
|
}
|
2017-10-12 20:35:19 +00:00
|
|
|
// Convert all 'proxy' UDP modules to 'forward' modules that specify which
|
|
|
|
// incoming ports are relevant. Primarily to make 'proxy' modules consistent
|
|
|
|
// in needing relevant domain names.
|
|
|
|
if (config.udp && !Array.isArray(config.udp.bind)) {
|
|
|
|
config.udp.bind = [].concat(config.udp.bind || []);
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
if (config.udp && config.udp.modules) {
|
|
|
|
if (!config.udp.bind.length || !Array.isArray(config.udp.modules)) {
|
|
|
|
delete config.udp.modules;
|
|
|
|
updated = true;
|
|
|
|
} else {
|
|
|
|
config.udp.modules.forEach(function (mod) {
|
|
|
|
if (mod.type === 'proxy') {
|
|
|
|
mod.type = 'forward';
|
|
|
|
mod.ports = config.udp.bind.slice();
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2017-10-11 18:11:20 +00:00
|
|
|
|
2017-10-12 17:57:43 +00:00
|
|
|
// This we take the old way of defining ACME options and put them into a tls module.
|
|
|
|
if (config.tls) {
|
|
|
|
var oldPropMap = {
|
|
|
|
email: 'email'
|
|
|
|
, acme_directory_url: 'server'
|
|
|
|
, challenge_type: 'challenge_type'
|
|
|
|
, servernames: 'approved_domains'
|
|
|
|
};
|
|
|
|
if (Object.keys(oldPropMap).some(config.tls.hasOwnProperty, config.tls)) {
|
|
|
|
updated = true;
|
|
|
|
if (config.tls.acme) {
|
|
|
|
console.warn('TLS config has `acme` field and old style definitions');
|
|
|
|
} else {
|
|
|
|
config.tls.acme = {};
|
|
|
|
Object.keys(oldPropMap).forEach(function (oldKey) {
|
|
|
|
if (config.tls[oldKey]) {
|
|
|
|
config.tls.acme[oldPropMap[oldKey]] = config.tls[oldKey];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (config.tls.acme) {
|
|
|
|
updated = true;
|
|
|
|
config.tls.acme.domains = config.tls.acme.approved_domains;
|
|
|
|
delete config.tls.acme.approved_domains;
|
|
|
|
config.tls.modules = config.tls.modules || [];
|
|
|
|
config.tls.modules.push(Object.assign({}, config.tls.acme, {type: 'acme'}));
|
|
|
|
delete config.tls.acme;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then we make sure all modules have an ID and type, and makes sure all domains
|
|
|
|
// are in the right spot and also have an ID.
|
2017-10-05 00:27:29 +00:00
|
|
|
function updateModules(list) {
|
|
|
|
if (!Array.isArray(list)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
list.forEach(function (mod) {
|
|
|
|
if (!mod.id) {
|
2017-10-06 00:10:59 +00:00
|
|
|
mod.id = crypto.randomBytes(4).toString('hex');
|
2017-10-05 00:27:29 +00:00
|
|
|
updated = true;
|
|
|
|
}
|
2017-10-06 00:11:58 +00:00
|
|
|
if (mod.name) {
|
|
|
|
mod.type = mod.type || mod.name;
|
|
|
|
delete mod.name;
|
|
|
|
updated = true;
|
|
|
|
}
|
2017-10-05 00:27:29 +00:00
|
|
|
});
|
|
|
|
}
|
2017-10-11 18:11:20 +00:00
|
|
|
function moveDomains(name) {
|
|
|
|
if (!config[name].domains) {
|
2017-10-05 00:27:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-10-11 18:11:20 +00:00
|
|
|
updated = true;
|
|
|
|
var domList = config[name].domains;
|
|
|
|
delete config[name].domains;
|
|
|
|
|
|
|
|
if (!Array.isArray(domList)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!Array.isArray(config.domains)) {
|
|
|
|
config.domains = [];
|
|
|
|
}
|
|
|
|
domList.forEach(function (dom) {
|
|
|
|
updateModules(dom.modules);
|
|
|
|
|
|
|
|
var strDoms = dom.names.slice().sort().join(',');
|
2017-10-11 19:06:24 +00:00
|
|
|
var added = config.domains.some(function (existing) {
|
2017-10-11 18:11:20 +00:00
|
|
|
if (strDoms !== existing.names.slice().sort().join(',')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
existing.modules = existing.modules || {};
|
|
|
|
existing.modules[name] = (existing.modules[name] || []).concat(dom.modules);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
if (added) {
|
|
|
|
return;
|
2017-10-05 00:27:29 +00:00
|
|
|
}
|
2017-10-11 18:11:20 +00:00
|
|
|
|
|
|
|
var newDom = {
|
2017-10-12 17:57:43 +00:00
|
|
|
id: crypto.randomBytes(4).toString('hex')
|
|
|
|
, names: dom.names
|
|
|
|
, modules: {}
|
2017-10-11 18:11:20 +00:00
|
|
|
};
|
|
|
|
newDom.modules[name] = dom.modules;
|
|
|
|
config.domains.push(newDom);
|
2017-10-05 00:27:29 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-11 18:11:20 +00:00
|
|
|
[ 'udp', 'tcp', 'http', 'tls' ].forEach(function (key) {
|
2017-10-05 00:27:29 +00:00
|
|
|
if (!config[key]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
updateModules(config[key].modules);
|
2017-10-11 18:11:20 +00:00
|
|
|
moveDomains(key);
|
2017-10-05 00:27:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return updated;
|
|
|
|
}
|
|
|
|
async function createStorage(filename, filetype) {
|
2017-06-09 17:18:05 +00:00
|
|
|
var recase = require('recase').create({});
|
|
|
|
var snakeCopy = recase.snakeCopy.bind(recase);
|
|
|
|
var camelCopy = recase.camelCopy.bind(recase);
|
2017-04-27 02:16:47 +00:00
|
|
|
|
2017-06-09 17:18:05 +00:00
|
|
|
var parse, dump;
|
|
|
|
if (filetype === 'json') {
|
|
|
|
parse = JSON.parse;
|
|
|
|
dump = function (arg) { return JSON.stringify(arg, null, ' '); };
|
|
|
|
} else {
|
|
|
|
var yaml = require('js-yaml');
|
|
|
|
parse = function (text) { return yaml.safeLoad(text) || {}; };
|
|
|
|
dump = yaml.safeDump;
|
|
|
|
}
|
2016-09-13 23:08:08 +00:00
|
|
|
|
2017-10-05 00:27:29 +00:00
|
|
|
async function read() {
|
|
|
|
var text;
|
|
|
|
try {
|
|
|
|
text = await fs.readFileAsync(filename);
|
|
|
|
} catch (err) {
|
2017-09-20 00:23:43 +00:00
|
|
|
if (err.code === 'ENOENT') {
|
2017-10-05 00:27:29 +00:00
|
|
|
return {};
|
2017-09-20 00:23:43 +00:00
|
|
|
}
|
2017-10-05 00:27:29 +00:00
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
|
|
|
|
var rawConfig = parse(text);
|
|
|
|
if (fixRawConfig(rawConfig)) {
|
|
|
|
await fs.writeFileAsync(filename, dump(rawConfig));
|
|
|
|
text = await fs.readFileAsync(filename);
|
|
|
|
rawConfig = parse(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rawConfig;
|
2016-09-13 23:08:08 +00:00
|
|
|
}
|
2016-10-06 22:42:38 +00:00
|
|
|
|
2017-06-09 17:18:05 +00:00
|
|
|
var result = {
|
|
|
|
read: function () {
|
|
|
|
return read().then(camelCopy);
|
2016-10-06 22:42:38 +00:00
|
|
|
}
|
2017-06-09 17:18:05 +00:00
|
|
|
, save: function (changes) {
|
|
|
|
if (!changes || typeof changes !== 'object' || Array.isArray(changes)) {
|
|
|
|
return PromiseA.reject(new Error('invalid config'));
|
2016-10-06 22:42:38 +00:00
|
|
|
}
|
2017-06-09 17:18:05 +00:00
|
|
|
changes = snakeCopy(changes);
|
|
|
|
return read()
|
|
|
|
.then(snakeCopy)
|
|
|
|
.then(function (current) {
|
|
|
|
mergeSettings(current, changes);
|
|
|
|
// TODO: validate/lint the config before we actually write it.
|
|
|
|
return dump(current);
|
|
|
|
})
|
|
|
|
.then(function (newText) {
|
|
|
|
return fs.writeFileAsync(filename, newText);
|
|
|
|
})
|
|
|
|
.then(function () {
|
|
|
|
return result.read();
|
|
|
|
})
|
|
|
|
;
|
2016-10-06 22:42:38 +00:00
|
|
|
}
|
2017-06-09 17:18:05 +00:00
|
|
|
};
|
|
|
|
return result;
|
|
|
|
}
|
2017-10-05 00:27:29 +00:00
|
|
|
async function checkConfigLocation(cwd, configFile) {
|
2017-06-09 17:18:05 +00:00
|
|
|
cwd = cwd || process.cwd();
|
|
|
|
var path = require('path');
|
2017-10-05 00:27:29 +00:00
|
|
|
var filename, text;
|
2017-06-09 17:18:05 +00:00
|
|
|
|
|
|
|
if (configFile) {
|
|
|
|
filename = path.resolve(cwd, configFile);
|
2017-10-05 00:27:29 +00:00
|
|
|
try {
|
|
|
|
text = await fs.readFileAsync(filename);
|
|
|
|
} catch (err) {
|
|
|
|
if (err.code !== 'ENOENT') {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
if (path.extname(filename) === '.json') {
|
|
|
|
return { name: filename, type: 'json' };
|
|
|
|
} else {
|
|
|
|
return { name: filename, type: 'yaml' };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Note that `path.resolve` can handle both relative and absolute paths.
|
|
|
|
var defLocations = [
|
|
|
|
path.resolve(cwd, 'goldilocks.yml')
|
|
|
|
, path.resolve(cwd, 'goldilocks.json')
|
|
|
|
, path.resolve(cwd, 'etc/goldilocks/goldilocks.yml')
|
|
|
|
, '/etc/goldilocks/goldilocks.yml'
|
|
|
|
];
|
|
|
|
|
|
|
|
var ind;
|
|
|
|
for (ind = 0; ind < defLocations.length; ind += 1) {
|
|
|
|
try {
|
|
|
|
text = await fs.readFileAsync(defLocations[ind]);
|
|
|
|
filename = defLocations[ind];
|
|
|
|
break;
|
|
|
|
} catch (err) {
|
2017-06-12 17:38:18 +00:00
|
|
|
if (err.code !== 'ENOENT') {
|
2017-10-05 00:27:29 +00:00
|
|
|
throw err;
|
2017-06-12 17:38:18 +00:00
|
|
|
}
|
2017-10-05 00:27:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!filename) {
|
|
|
|
filename = defLocations[0];
|
|
|
|
text = '';
|
|
|
|
}
|
2016-10-06 22:42:38 +00:00
|
|
|
}
|
|
|
|
|
2017-10-05 00:27:29 +00:00
|
|
|
try {
|
|
|
|
JSON.parse(text);
|
|
|
|
return { name: filename, type: 'json' };
|
|
|
|
} catch (err) {}
|
2017-05-15 22:16:15 +00:00
|
|
|
|
2017-10-05 00:27:29 +00:00
|
|
|
try {
|
|
|
|
require('js-yaml').safeLoad(text);
|
|
|
|
return { name: filename, type: 'yaml' };
|
|
|
|
} catch (err) {}
|
2017-06-09 17:18:05 +00:00
|
|
|
|
2017-10-05 00:27:29 +00:00
|
|
|
throw new Error('Could not load "' + filename + '" as JSON nor YAML');
|
2017-06-09 17:18:05 +00:00
|
|
|
}
|
2017-10-05 00:27:29 +00:00
|
|
|
async function createConfigStorage(args) {
|
|
|
|
var result = await checkConfigLocation(args.cwd, args.config);
|
|
|
|
console.log('config file', result.name, 'is of type', result.type);
|
|
|
|
configStorage = await createStorage(result.name, result.type);
|
|
|
|
return configStorage.read();
|
2017-06-09 17:18:05 +00:00
|
|
|
}
|
|
|
|
|
2017-06-09 18:40:39 +00:00
|
|
|
var tcpProm;
|
2017-06-09 17:18:05 +00:00
|
|
|
function fillConfig(config, args) {
|
2017-05-25 00:20:02 +00:00
|
|
|
config.debug = config.debug || args.debug;
|
2017-05-15 22:16:15 +00:00
|
|
|
|
2017-10-06 23:50:16 +00:00
|
|
|
config.socks5 = config.socks5 || { enabled: false };
|
2017-04-27 02:16:47 +00:00
|
|
|
|
2017-10-05 00:26:27 +00:00
|
|
|
// Use Object.assign to copy any real config values over the default values so we can
|
|
|
|
// easily make sure all the fields we need exist .
|
|
|
|
var mdnsDefaults = { disabled: false, port: 5353, broadcast: '224.0.0.251', ttl: 300 };
|
|
|
|
config.mdns = Object.assign(mdnsDefaults, config.mdns);
|
2017-04-27 22:50:03 +00:00
|
|
|
|
2017-10-11 19:06:24 +00:00
|
|
|
if (!Array.isArray(config.domains)) {
|
|
|
|
config.domains = [];
|
|
|
|
}
|
2017-04-27 22:50:03 +00:00
|
|
|
|
2017-10-11 19:06:24 +00:00
|
|
|
function fillComponent(name, fillBind) {
|
2017-10-05 00:26:27 +00:00
|
|
|
if (!config[name]) {
|
|
|
|
config[name] = {};
|
|
|
|
}
|
|
|
|
if (!Array.isArray(config[name].modules)) {
|
|
|
|
config[name].modules = [];
|
2017-04-27 22:50:03 +00:00
|
|
|
}
|
|
|
|
|
2017-10-05 00:26:27 +00:00
|
|
|
if (fillBind && !Array.isArray(config[name].bind)) {
|
|
|
|
config[name].bind = [];
|
|
|
|
}
|
2017-05-25 00:20:02 +00:00
|
|
|
}
|
2017-10-11 19:06:24 +00:00
|
|
|
fillComponent('udp', true);
|
|
|
|
fillComponent('tcp', true);
|
|
|
|
fillComponent('http', false);
|
|
|
|
fillComponent('tls', false);
|
2017-10-18 18:06:01 +00:00
|
|
|
fillComponent('ddns', false);
|
2017-04-27 22:50:03 +00:00
|
|
|
|
2017-06-09 17:18:05 +00:00
|
|
|
config.device = { hostname: require('os').hostname() };
|
2017-04-27 22:50:03 +00:00
|
|
|
|
2017-10-05 00:26:27 +00:00
|
|
|
if (Array.isArray(config.tcp.bind) && config.tcp.bind.length) {
|
2017-06-09 18:40:39 +00:00
|
|
|
return PromiseA.resolve(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We need to make sure we only check once, because even though our workers can
|
|
|
|
// all bind on the same port witout issue we cannot. This will lead to failure
|
|
|
|
// to determine which ports will work once the first worker starts.
|
|
|
|
if (!tcpProm) {
|
2017-05-03 19:55:16 +00:00
|
|
|
tcpProm = new PromiseA(function (resolve, reject) {
|
|
|
|
require('../lib/check-ports').checkTcpPorts(function (failed, bound) {
|
2017-06-09 18:40:39 +00:00
|
|
|
var result = Object.keys(bound).map(Number);
|
|
|
|
if (result.length > 0) {
|
|
|
|
resolve(result);
|
2017-05-03 19:55:16 +00:00
|
|
|
} else {
|
|
|
|
reject(failed);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2017-04-27 02:16:47 +00:00
|
|
|
}
|
|
|
|
|
2017-06-09 18:40:39 +00:00
|
|
|
return tcpProm.then(
|
|
|
|
function (bound) {
|
|
|
|
config.tcp.bind = bound;
|
|
|
|
return config;
|
2017-06-09 22:03:12 +00:00
|
|
|
}, function (failed) {
|
2017-04-27 02:16:47 +00:00
|
|
|
Object.keys(failed).forEach(function (key) {
|
|
|
|
console.log('[error bind]', key, failed[key].code);
|
|
|
|
});
|
2017-06-09 18:14:25 +00:00
|
|
|
return PromiseA.reject(new Error("could not bind to the default ports"));
|
2017-05-03 19:55:16 +00:00
|
|
|
});
|
2017-04-27 02:16:47 +00:00
|
|
|
}
|
|
|
|
|
2017-06-09 17:18:05 +00:00
|
|
|
function run(args) {
|
|
|
|
var workers = {};
|
|
|
|
var cachedConfig;
|
|
|
|
|
2017-09-20 00:23:43 +00:00
|
|
|
function updateConfig(config) {
|
|
|
|
fillConfig(config, args).then(function (config) {
|
|
|
|
cachedConfig = config;
|
|
|
|
console.log('changed config', config);
|
|
|
|
Object.keys(workers).forEach(function (key) {
|
|
|
|
workers[key].send(cachedConfig);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
process.on('SIGHUP', function () {
|
|
|
|
configStorage.read().then(updateConfig).catch(function (err) {
|
|
|
|
console.error('error updating config after SIGHUP', err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-09 17:18:05 +00:00
|
|
|
cluster.on('message', function (worker, message) {
|
2017-06-26 17:34:42 +00:00
|
|
|
if (message.type !== 'com.daplie.goldilocks/config') {
|
2017-06-09 17:18:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-09-20 00:23:43 +00:00
|
|
|
configStorage.save(message.changes).then(updateConfig).catch(function (err) {
|
|
|
|
console.error('error changing config', err);
|
|
|
|
});
|
2017-06-09 17:18:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
cluster.on('online', function (worker) {
|
|
|
|
console.log('[worker]', worker.id, 'online');
|
|
|
|
workers[worker.id] = worker;
|
|
|
|
// Worker is listening
|
|
|
|
worker.send(cachedConfig);
|
|
|
|
});
|
|
|
|
|
|
|
|
cluster.on('exit', function (worker) {
|
|
|
|
delete workers[worker.id];
|
|
|
|
cluster.fork();
|
|
|
|
});
|
|
|
|
|
|
|
|
createConfigStorage(args)
|
|
|
|
.then(function (config) {
|
|
|
|
return fillConfig(config, args);
|
|
|
|
})
|
|
|
|
.then(function (config) {
|
|
|
|
console.log('config.tcp.bind', config.tcp.bind);
|
|
|
|
cachedConfig = config;
|
|
|
|
// TODO spin up multiple workers
|
|
|
|
// TODO use greenlock-cluster
|
|
|
|
cluster.fork();
|
2017-10-11 19:06:24 +00:00
|
|
|
}).catch(function (err) {
|
|
|
|
console.error(err);
|
|
|
|
process.exit(1);
|
2017-06-09 17:18:05 +00:00
|
|
|
})
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2017-04-27 02:16:47 +00:00
|
|
|
function readEnv(args) {
|
|
|
|
// TODO
|
2017-05-25 00:20:02 +00:00
|
|
|
try {
|
|
|
|
if (process.env.GOLDILOCKS_HOME) {
|
|
|
|
process.chdir(process.env.GOLDILOCKS_HOME);
|
|
|
|
}
|
|
|
|
} catch (err) {}
|
|
|
|
|
2017-04-27 02:16:47 +00:00
|
|
|
var env = {
|
2017-10-17 19:07:52 +00:00
|
|
|
cwd: process.env.GOLDILOCKS_HOME || process.cwd()
|
2017-04-27 02:16:47 +00:00
|
|
|
, debug: process.env.GOLDILOCKS_DEBUG && true
|
|
|
|
};
|
2015-07-08 06:43:46 +00:00
|
|
|
|
2017-06-09 17:18:05 +00:00
|
|
|
run(Object.assign({}, env, args));
|
2017-04-13 23:42:37 +00:00
|
|
|
}
|
2016-08-06 18:34:15 +00:00
|
|
|
|
2017-05-06 18:04:46 +00:00
|
|
|
var program = require('commander');
|
|
|
|
|
|
|
|
program
|
|
|
|
.version(require('../package.json').version)
|
2017-05-08 19:00:45 +00:00
|
|
|
.option('-c --config <file>', 'Path to config file (Goldilocks.json or Goldilocks.yml) example: --config /etc/goldilocks/Goldilocks.json')
|
2017-05-06 18:04:46 +00:00
|
|
|
.option('--debug', "Enable debug output")
|
|
|
|
.parse(process.argv);
|
|
|
|
|
|
|
|
readEnv(program);
|