diff --git a/.gitignore b/.gitignore index e4435a8..a1446b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ node_modules tmp/ -config.json .nyc_output logs/ diff --git a/lib/config/config.json b/lib/config/config.json new file mode 100644 index 0000000..2b918bd --- /dev/null +++ b/lib/config/config.json @@ -0,0 +1,32 @@ +{ + "prod": { + "workers": 1, + "port": 9222, + "hostname": "127.0.0.1", + "upstream": "ws://localhost:9125", + "retryDelay": 10000, + "closeTimer": 15000, + "enableInstrumentation": true, + "instrumentationTimer": 60000 + }, + "test": { + "workers": 1, + "port": 8999, + "hostname": "127.0.0.1", + "upstream": "ws://localhost:8999", + "retryDelay": 10000, + "closeTimer": 15000, + "enableInstrumentation": true, + "instrumentationTimer": 60000 + }, + "dev": { + "workers": 1, + "port": 9222, + "hostname": "127.0.0.1", + "upstream": "ws://localhost:9125", + "retryDelay": 10000, + "closeTimer": 15000, + "enableInstrumentation": true, + "instrumentationTimer": 60000 + } +} diff --git a/lib/config/config.json.sample b/lib/config/config.json.sample index 58a4227..2b918bd 100644 --- a/lib/config/config.json.sample +++ b/lib/config/config.json.sample @@ -1,7 +1,7 @@ { "prod": { "workers": 1, - "port": 9124, + "port": 9222, "hostname": "127.0.0.1", "upstream": "ws://localhost:9125", "retryDelay": 10000, @@ -21,7 +21,7 @@ }, "dev": { "workers": 1, - "port": 9124, + "port": 9222, "hostname": "127.0.0.1", "upstream": "ws://localhost:9125", "retryDelay": 10000, diff --git a/lib/config/constants.js b/lib/config/constants.js index eb4fe11..296d9b9 100644 --- a/lib/config/constants.js +++ b/lib/config/constants.js @@ -112,15 +112,25 @@ class ConfigParser { setUpstream() { this.upstream = config.upstream; + + if (process.env.CDP_UPSTREAM) { + this.upstream = process.env.CDP_UPSTREAM; + } + return this; } setPort() { - const { port } = config; + let { port } = config; + + if (process.env.CDP_PORT) { + port = Number(process.env.CDP_PORT); + } + let portVal; if (isNotNumber(port)) { - logger.info('Not a valid port number, using default (8081)'); - portVal = 8081; + logger.info('Not a valid port number, using default (9222)'); + portVal = 9222; } else { portVal = port; } @@ -129,7 +139,12 @@ class ConfigParser { } setHostname() { - const { hostname } = config; + let { hostname } = config; + + if (process.env.HOST) { + hostname = process.env.HOST; + } + let hostnameVal; if (isNotString(hostname)) { logger.info('Not a valid port number, using default (8081)');