UNPKG

guvnor

Version:

A node process manager that isn't spanners all the way down

29 lines (22 loc) 802 B
var Autowire = require('wantsit').Autowire // Loads config from the parent process var ConfigLoader = function (prefix) { this._prefix = prefix || 'process' this._parentProcess = Autowire this._coercer = Autowire } ConfigLoader.prototype.afterPropertiesSet = function (done) { // notify once config has been loaded from parent process this._parentProcess.once('daemon:config:response', function (config) { Object.keys(config).forEach(function (key) { if (key.substring(0, 1) === '_') { return } this[key] = this._coercer(config[key]) }.bind(this)) done() }.bind(this)) // request config from parent process process.nextTick(this._parentProcess.send.bind(this._parentProcess, this._prefix + ':config:request')) } module.exports = ConfigLoader