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
|
||||
if(typeof process.env.DB_URL == 'undefined' || typeof process.env.DB_NAME == 'undefined') {
|
||||
if(typeof process.env.DB_URL == 'undefined') console.error("environment variable DB_URL is not set");
|
||||
if(typeof process.env.DB_NAME == 'undefined') console.error("environment variable DB_NAME is not set");
|
||||
process.exit();
|
||||
}
|
||||
let env_vars = ["DB_URL", "DB_NAME"];
|
||||
let env_missing = false;
|
||||
env_vars.forEach((el) => {
|
||||
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'].cli = load('cli'); // command line interface
|
||||
|
Loading…
x
Reference in New Issue
Block a user