bin/moleculer-runner.js
function mergeOptions() {

	config = _.defaultsDeep(configFile, Moleculer.ServiceBroker.defaultOptions);
	if (config.logger == null && !flags.silent)
		config.logger = console;

	function normalizeEnvValue(value) {
		if (value.toLowerCase() === "true" || value.toLowerCase() === "false") {
			// Convert to boolean
			value = value === "true";
		} else if (!isNaN(value)) {
			// Convert to number
			value = Number(value);
		}
		return value;
	}

	function overwriteFromEnv(obj, prefix) {
		Object.keys(obj).forEach(key => {

			const envName = ((prefix ? prefix + "_" : "") + key).toUpperCase();

			if (process.env[envName]) {
				obj[key] = normalizeEnvValue(process.env[envName]);
			}

			if (_.isPlainObject(obj[key]))
				obj[key] = overwriteFromEnv(obj[key], (prefix ? prefix + "_" : "") + key);
		});

		const moleculerPrefix = "MOL_";
		Object.keys(process.env)
			.filter(key => key.startsWith(moleculerPrefix))
			.map(key => ({
				key,
				withoutPrefix: key.substr(moleculerPrefix.length)
			}))
			.forEach(variable => {
				const dotted = variable.withoutPrefix
					.split("__")
					.map(level => level.toLocaleLowerCase())
					.map(level =>
						level
							.split("_")
							.map((value, index) => {
								if (index == 0) {
									return value;
								} else {
									return value[0].toUpperCase() + value.substring(1);
								}
							})
							.join("")
					)
					.join(".");
				obj = utils.dotSet(obj, dotted, normalizeEnvValue(process.env[variable.key]));
			});

		return obj;
	}

	config = overwriteFromEnv(config);

	if (flags.silent) {
		config.logger = null;
	}

	if (flags.hot) {
		config.hotReload = true;
	}

	//console.log("Config", config);
}
function mergeOptions() {

	config = _.defaultsDeep(configFile, Moleculer.ServiceBroker.defaultOptions);
	if (config.logger == null && !flags.silent)
		config.logger = console;

	function normalizeEnvValue(value) {
		if (value.toLowerCase() === "true" || value.toLowerCase() === "false") {
			// Convert to boolean
			value = value === "true";
		} else if (!isNaN(value)) {
			// Convert to number
			value = Number(value);
		}
		return value;
	}

	function overwriteFromEnv(obj, prefix) {
		Object.keys(obj).forEach(key => {

			const envName = ((prefix ? prefix + "_" : "") + key).toUpperCase();

			if (process.env[envName]) {
				obj[key] = normalizeEnvValue(process.env[envName]);
			}

			if (_.isPlainObject(obj[key]))
				obj[key] = overwriteFromEnv(obj[key], (prefix ? prefix + "_" : "") + key);
		});

		const moleculerPrefix = "MOL_";
		Object.keys(process.env)
			.filter(key => key.startsWith(moleculerPrefix))
			.map(key => ({
				key,
				withoutPrefix: key.substr(moleculerPrefix.length)
			}))
			.forEach(variable => {
				const dotted = variable.withoutPrefix
					.split("__")
					.map(level => level.toLocaleLowerCase())
					.map(level =>
						level
							.split("_")
							.map((value, index) => {
								if (index == 0) {
									return value;
								} else {
									return value[0].toUpperCase() + value.substring(1);
								}
							})
							.join("")
					)
					.join(".");
				obj = utils.dotSet(obj, dotted, normalizeEnvValue(process.env[variable.key]));
			});

		return obj;
	}

	config = overwriteFromEnv(config);

	if (flags.silent) {
		config.logger = null;
	}

	if (flags.hot) {
		config.hotReload = true;
	}

	//console.log("Config", config);
}
function mergeOptions ( ) { config = _ . defaultsDeep ( configFile , Moleculer . ServiceBroker . defaultOptions ) ; if ( config . logger == null && ! flags . silent ) config . logger = console ; function normalizeEnvValue ( value ) { if ( value . toLowerCase ( ) === "true" || value . toLowerCase ( ) === "false" ) { // Convert to boolean value = value === "true" ; } else if ( ! isNaN ( value ) ) { // Convert to number value = Number ( value ) ; } return value ; } function overwriteFromEnv ( obj , prefix ) { Object . keys ( obj ) . forEach ( key => { const envName = ( ( prefix ? prefix + "_" : "" ) + key ) . toUpperCase ( ) ; if ( process . env [ envName ] ) { obj [ key ] = normalizeEnvValue ( process . env [ envName ] ) ; } if ( _ . isPlainObject ( obj [ key ] ) ) obj [ key ] = overwriteFromEnv ( obj [ key ] , ( prefix ? prefix + "_" : "" ) + key ) ; } ) ; const moleculerPrefix = "MOL_" ; Object . keys ( process . env ) . filter ( key => key . startsWith ( moleculerPrefix ) ) . map ( key => ( { key , withoutPrefix : key . substr ( moleculerPrefix . length ) } ) ) . forEach ( variable => { const dotted = variable . withoutPrefix . split ( "__" ) . map ( level => level . toLocaleLowerCase ( ) ) . map ( level => level . split ( "_" ) . map ( ( value , index ) => { if ( index == 0 ) { return value ; } else { return value [ 0 ] . toUpperCase ( ) + value . substring ( 1 ) ; } } ) . join ( "" ) ) . join ( "." ) ; obj = utils . dotSet ( obj , dotted , normalizeEnvValue ( process . env [ variable . key ] ) ) ; } ) ; return obj ; } config = overwriteFromEnv ( config ) ; if ( flags . silent ) { config . logger = null ; } if ( flags . hot ) { config . hotReload = true ; } //console.log("Config", config); }
Merge broker options

Merge options from environment variables and config file. First
load the config file if exists. After it overwrite the vars from
the environment values.

Example options:

Original broker option: `logLevel`
Config file property: 	`logLevel`
Env variable:			`LOGLEVEL`

Original broker option: `circuitBreaker.enabled`
Config file property: 	`circuitBreaker.enabled`
Env variable:			`CIRCUITBREAKER_ENABLED`
Merge broker options