app - environment variable check
This commit is contained in:
parent
40c3d0f160
commit
e0eb4244b6
14
app.js
14
app.js
@ -23,11 +23,15 @@ let load = (name) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// environment variable check
|
// environment variable check
|
||||||
if(typeof process.env.DB_URL == 'undefined' || typeof process.env.DB_NAME == 'undefined') {
|
let env_vars = ["DB_URL", "DB_NAME"];
|
||||||
if(typeof process.env.DB_URL == 'undefined') console.error("environment variable DB_URL is not set");
|
let env_missing = false;
|
||||||
if(typeof process.env.DB_NAME == 'undefined') console.error("environment variable DB_NAME is not set");
|
env_vars.forEach((el) => {
|
||||||
process.exit();
|
if(typeof process.env[el] == 'undefined') {
|
||||||
}
|
console.error("environment variable "+el+" is not set");
|
||||||
|
env_missing = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(env_missing) process.exit();
|
||||||
|
|
||||||
global['modules'].events = load('events'); // event handler
|
global['modules'].events = load('events'); // event handler
|
||||||
global['modules'].cli = load('cli'); // command line interface
|
global['modules'].cli = load('cli'); // command line interface
|
||||||
|
Loading…
x
Reference in New Issue
Block a user