Implement env-var-checks

f_influxdb-line-protocol
Ruakij 3 years ago
parent f596a99ee6
commit 1012001312

@ -25,12 +25,17 @@ const env = process.env;
env.LOGLEVEL ??= "INFO"; env.LOGLEVEL ??= "INFO";
env.WIFI_INTERFACE ??= "wlan0"; env.WIFI_INTERFACE ??= "wlan0";
env.HOSTNAME ??= Os.hostname(); env.HOSTNAME ??= Os.hostname();
env.USE_INFLUXDB_LINEPROTOCOL ??= false;
} }
// Required vars // Required vars
let errorMsg = requireEnvVars([ let errorMsg = requireEnvVars(
"INFLUX_URL", "INFLUX_TOKEN", env.USE_INFLUXDB_LINEPROTOCOL? [ // When lineprotocol is enabled, we need host and port
"INFLUX_ORG", "INFLUX_BUCKET" "INFLUXDB_LINEPROTOCOL_HOST", "INFLUXDB_LINEPROTOCOL_PORT",
]); ] : [ // When its disabled, influxdb-data
"INFLUX_URL", "INFLUX_TOKEN",
"INFLUX_ORG", "INFLUX_BUCKET"
]);
if(errorMsg){ if(errorMsg){
logger.fatal(errorMsg); logger.fatal(errorMsg);
exit(1); exit(1);

Loading…
Cancel
Save