Accept configuration from environment variables or command line arguments. Unified cluster and HTTP server code for CWMP, NBI, and FS.
This commit is contained in:
1 parent
5d0f398bf7
commit
32c56f8ff1
14 files changed
+511
-485
No files matched your search
+86
-34
@@ -15,43 +15,95 @@
|
||||
# along with GenieACS. If not, see <http://www.gnu.org/licenses/>.
|
||||
###
|
||||
|
||||
exports.MONGODB_CONNECTION_URL = 'mongodb://localhost/genieacs'
|
||||
exports.REDIS_DB = 0
|
||||
exports.ACS_PORT = 7547 # CWMP port as assigned by IANA
|
||||
exports.ACS_HTTPS_PORT = 7548
|
||||
exports.ACS_INTERFACE = '0.0.0.0'
|
||||
exports.ACS_HTTPS_INTERFACE = '0.0.0.0'
|
||||
exports.API_PORT = 7557
|
||||
exports.API_INTERFACE = '0.0.0.0'
|
||||
exports.FILES_PORT = 7567
|
||||
exports.FILES_INTERFACE = '0.0.0.0'
|
||||
exports.FILES_IP = '172.240.21.2' # Used when sending download requests to devices
|
||||
exports.CACHE_DURATION = 60 # in seconds
|
||||
exports.PRESETS_CACHE_DURATION = 86400
|
||||
exports.PRESETS_TIME_PADDING = 1
|
||||
exports.MONGODB_SOCKET = '/tmp/mongodb-27017.sock'
|
||||
exports.REDIS_SOCKET = '/tmp/redis.sock'
|
||||
exports.WORKER_RESPAWN_TIME = 60000
|
||||
exports.LOG_INFORMS = false
|
||||
exports.DEBUG_DEVICES = {} # {'202BC1-BM632w-8KA8WA1151100043' : true}
|
||||
exports.DEVICE_ONLINE_THRESHOLD = 4000
|
||||
exports.RETRY_DELAY = 300
|
||||
exports.IGNORE_XML_NAMESPACES = false # Traverse XML using element's local name only
|
||||
exports.LIBXMLJS_OPTIONS = {} # Options passed directly to libxmljs
|
||||
exports.SESSION_TIMEOUT = 30
|
||||
exports.GET_PARAMETER_NAMES_DEPTH_THRESHOLD = 0
|
||||
exports.TASK_PARAMETERS_BATCH_SIZE = 32
|
||||
path = require 'path'
|
||||
common = require './common'
|
||||
|
||||
|
||||
defaults = {
|
||||
CONFIG_DIR : './config',
|
||||
|
||||
MONGODB_CONNECTION_URL : 'mongodb://127.0.0.1/genieacs',
|
||||
REDIS_PORT : 6379,
|
||||
REDIS_HOST : '127.0.0.1',
|
||||
REDIS_DB : 0,
|
||||
|
||||
CWMP_WORKER_PROCESSES : 4,
|
||||
CWMP_PORT : 7547, # CWMP port as assigned by IANA
|
||||
CWMP_INTERFACE : '0.0.0.0',
|
||||
CWMP_SSL : false,
|
||||
NBI_WORKER_PROCESSES : 2,
|
||||
NBI_PORT : 7557,
|
||||
NBI_INTERFACE : '0.0.0.0',
|
||||
NBI_SSL : false,
|
||||
FS_WORKER_PROCESSES : 2,
|
||||
FS_PORT : 7567,
|
||||
FS_INTERFACE : '0.0.0.0',
|
||||
FS_SSL : false,
|
||||
FILES_IP : '192.168.0.1', # Used when sending download requests to devices
|
||||
|
||||
CACHE_DURATION : 60, # in seconds
|
||||
PRESETS_CACHE_DURATION : 86400,
|
||||
PRESETS_TIME_PADDING : 1,
|
||||
|
||||
LOG_INFORMS : true,
|
||||
DEBUG : false,
|
||||
DEVICE_ONLINE_THRESHOLD : 4000,
|
||||
RETRY_DELAY : 300,
|
||||
IGNORE_XML_NAMESPACES : false, # Traverse XML using element's local name only
|
||||
SESSION_TIMEOUT : 30,
|
||||
GET_PARAMETER_NAMES_DEPTH_THRESHOLD : 0,
|
||||
TASK_PARAMETERS_BATCH_SIZE : 32
|
||||
}
|
||||
|
||||
|
||||
# Command line arguments
|
||||
exports.argv = []
|
||||
argv = process.argv[2..]
|
||||
while argv.length
|
||||
arg = argv.shift()
|
||||
if arg[0] == '-'
|
||||
v = argv.shift()
|
||||
exports.argv[arg] = v
|
||||
n = arg[2..].toUpperCase().replace(/-/g, '_')
|
||||
if defaults[n]?
|
||||
exports[n] ?= common.matchType(defaults[n], v)
|
||||
# Save as environmnet variables to pass on to any child processes
|
||||
process.env["GENIEACS_#{n}"] = v
|
||||
else
|
||||
exports.argv.push(arg)
|
||||
|
||||
|
||||
# Environment variable
|
||||
for k, v of process.env
|
||||
k = k[9..] # remove "GENIEACS_" prefix
|
||||
if defaults[k]?
|
||||
exports[k] ?= common.matchType(defaults[k], v)
|
||||
|
||||
|
||||
# Find config dir
|
||||
if exports.argv['--config-dir']?
|
||||
exports.CONFIG_DIR = exports.argv['--config-dir']
|
||||
else if process.env['GENIEACS_CONFIG_DIR']?
|
||||
exports.CONFIG_DIR = process.env['GENIEACS_CONFIG_DIR']
|
||||
else
|
||||
exports.CONFIG_DIR = defaults.CONFIG_DIR
|
||||
|
||||
|
||||
# Configuration file
|
||||
for k, v of require(path.resolve(exports.CONFIG_DIR, 'config'))
|
||||
if defaults[k]?
|
||||
exports[k] ?= common.matchType(defaults[k], v)
|
||||
|
||||
|
||||
# Defaults
|
||||
for k, v of defaults
|
||||
exports[k] ?= defaults[k]
|
||||
|
||||
# load configuration
|
||||
c = require('../config/config')
|
||||
for k, v of c
|
||||
exports[k] = v
|
||||
|
||||
# load parameter configurations
|
||||
exports.PARAMETERS = require('../config/parameters')
|
||||
exports.PARAMETERS = require(path.resolve(exports.CONFIG_DIR, 'parameters'))
|
||||
|
||||
# load authentication scripts
|
||||
exports.auth = require('../config/auth')
|
||||
|
||||
exports.CUSTOM_COMMANDS = require('../config/custom_commands')
|
||||
exports.auth = require(path.resolve(exports.CONFIG_DIR, 'auth'))
|
||||
|
||||
exports.CUSTOM_COMMANDS = require(path.resolve(exports.CONFIG_DIR, 'custom_commands'))
|
||||
Reference in new issue
Block a user