Update server configs to read ENV-VARS
This commit is contained in:
parent
4f603eb6f9
commit
955b1e75c1
15
README.md
15
README.md
@ -59,4 +59,19 @@ To run this server you will need:
|
||||
- utils -> Provide utility functions that can be called by services.
|
||||
- configs -> Provide configuration details for other files.
|
||||
- static -> Holds files for static service, should be hosted behind a caching proxy.
|
||||
|
||||
## Configuration:
|
||||
The app is designed to be run within Kubernetes or within a Docker container, as such configuration is provided with environment variables. See the variable name and default options below. If a required configuration is not present the program will exit.
|
||||
|
||||
|VAR|DEFAULT|REQUIRED|PURPOSE|
|
||||
|:-:|:-----:|:------:|:-----:|
|
||||
|OWL_SRV_PORT|8460|NO|Web Server Port|
|
||||
|OWL_SRV_LISTEN|0.0.0.0|NO|Web Server Listen Address|
|
||||
|OWL_DB_USER||YES|Database Username|
|
||||
|OWL_DB_PASS||YES|Database Password|
|
||||
|OWL_DB_NAME||YES|Database Name|
|
||||
|OWL_DB_PORT||YES|Database Server Port|
|
||||
|OWL_DB_HOST||YES|Database Server Host|
|
||||
|OWL_LDB_KEY||YES|National Rail LDBWS API Key|
|
||||
|OWL_LDB_SVKEY||NO|National Rail LDBSVWS API Key|
|
||||
|
@ -1,3 +1,9 @@
|
||||
OWL_DB_USER
|
||||
OWL_DB_PASS
|
||||
OWL_DB_NAME
|
||||
OWL_DB_PORT
|
||||
OWL_DB_HOST
|
||||
|
||||
const database = {
|
||||
user: 'owlboard',
|
||||
password: 'owlboard',
|
||||
|
@ -1,6 +1,26 @@
|
||||
function getPort(){
|
||||
if (process.env.OWL_SRV_PORT){
|
||||
var confPort = process.env.OWL_SRV_PORT;
|
||||
} else {
|
||||
var confPort = 8460;
|
||||
};
|
||||
return Number(confPort);
|
||||
}
|
||||
|
||||
function getListen(){
|
||||
if (process.env.OWL_SRV_LISTEN){
|
||||
var confListen = process.env.OWL_SRV_LISTEN;
|
||||
} else {
|
||||
var confListen = "0.0.0.0"
|
||||
}
|
||||
return confListen;
|
||||
}
|
||||
|
||||
const server = {
|
||||
port: 8460,
|
||||
listen: "localhost"
|
||||
port: getPort(),
|
||||
listen: getListen()
|
||||
};
|
||||
|
||||
module.exports = server;
|
||||
module.exports = {
|
||||
server
|
||||
}
|
Reference in New Issue
Block a user