Pass config to extensions as env vars

This commit is contained in:
Zaid Abdulla committed 2016-11-30 21:52:48 -08:00
1 parent 68798b5b12
commit e0c1245062
2 files changed
+6 -9

No files matched your search

+2 -7
View File
@@ -19,11 +19,6 @@ config = require './config'
cluster = require 'cluster'
util = require 'util'
# Keep current configuration to pass that to workers as environment variables
ENVIRONMENT_VARIABLES = {}
for k, v of config.allConfig
ENVIRONMENT_VARIABLES["GENIEACS_#{k}"] = v
cluster.on('listening', (worker, address) ->
util.log("Worker #{worker.process.pid} listening to #{address.address}:#{address.port}")
@@ -31,7 +26,7 @@ cluster.on('listening', (worker, address) ->
cluster.on('exit', (worker, code, signal) ->
util.log("Worker #{worker.process.pid} died (#{worker.process.exitCode})")
cluster.fork(ENVIRONMENT_VARIABLES)
cluster.fork()
)
@@ -45,7 +40,7 @@ start = (service) ->
})
for [0 ... workerProcesses]
cluster.fork(ENVIRONMENT_VARIABLES)
cluster.fork()
exports.start = start
+4 -2
View File
@@ -100,7 +100,7 @@ setConfig = (name, value, commandLineArgument) ->
if _value?
allConfig[n] = _value
# Save as environmnet variable to pass on to any child processes
process.env[n] = _value
process.env["GENIEACS_#{n}"] = _value
return true
return false
@@ -137,7 +137,9 @@ else
# Configuration file
for k, v of require(path.resolve(allConfig.CONFIG_DIR, 'config'))
setConfig(k, v)
if not setConfig(k, v)
# Pass as environment variable to be accessable by extensions
process.env["GENIEACS_#{k}"] = v
# Defaults