Skip to content

Commit

Permalink
refactor: Remove support for old, long deprecated config file formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Göran Sander committed May 18, 2024
1 parent df98478 commit 1d6989e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 51 deletions.
51 changes: 10 additions & 41 deletions src/butler-sos.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ process.emit = function (name, data, ...args) {

globals.initInfluxDB();

if (
(globals.config.has('Butler-SOS.uptimeMonitor.enabled') &&
globals.config.get('Butler-SOS.uptimeMonitor.enabled') === true) ||
globals.config.get('Butler-SOS.uptimeMonitor.enable') === true
) {
if (globals.config.get('Butler-SOS.uptimeMonitor.enable') === true) {
serviceUptime.serviceUptimeStart();
}

Expand All @@ -78,11 +74,7 @@ async function mainScript() {
const caFile = path.resolve(process.cwd(), globals.config.get('Butler-SOS.cert.clientCertCA'));

// Set up heartbeats, if enabled in the config file
if (
(globals.config.has('Butler-SOS.heartbeat.enabled') &&
globals.config.get('Butler-SOS.heartbeat.enabled') === true) ||
globals.config.get('Butler-SOS.heartbeat.enable') === true
) {
if (globals.config.get('Butler-SOS.heartbeat.enable') === true) {
heartbeat.setupHeartbeatTimer(globals.config, globals.logger);
}

Expand Down Expand Up @@ -121,11 +113,7 @@ async function mainScript() {
globals.logger.info(`CA cert: ${caFile}`);

// Set up anon usage reports, if enabled
if (
globals.config.has('Butler-SOS.anonTelemetry') === false ||
(globals.config.has('Butler-SOS.anonTelemetry') === true &&
globals.config.get('Butler-SOS.anonTelemetry') === true)
) {
if (globals.config.get('Butler-SOS.anonTelemetry') === true) {
telemetry.setupAnonUsageReportTimer();
globals.logger.verbose('MAIN: Anonymous telemetry reporting has been set up.');
globals.logger.verbose(
Expand All @@ -137,10 +125,7 @@ async function mainScript() {
}

// Set up UDP handler for user activity/events
if (
globals.config.has('Butler-SOS.userEvents.enable') &&
globals.config.get('Butler-SOS.userEvents.enable')
) {
if (globals.config.get('Butler-SOS.userEvents.enable')) {
udpUserActivity.udpInitUserActivityServer();

globals.logger.debug(
Expand All @@ -156,12 +141,9 @@ async function mainScript() {

// Set up UDP handler for log events
if (
(globals.config.has('Butler-SOS.logEvents.source.repository.enable') &&
globals.config.get('Butler-SOS.logEvents.source.repository.enable')) ||
(globals.config.has('Butler-SOS.logEvents.source.scheduler.enable') &&
globals.config.get('Butler-SOS.logEvents.source.scheduler.enable')) ||
(globals.config.has('Butler-SOS.logEvents.source.proxy.enable') &&
globals.config.get('Butler-SOS.logEvents.source.proxy.enable'))
globals.config.get('Butler-SOS.logEvents.source.repository.enable') ||
globals.config.get('Butler-SOS.logEvents.source.scheduler.enable') ||
globals.config.get('Butler-SOS.logEvents.source.proxy.enable')
) {
udpLogEvents.udpInitLogEventServer();

Expand All @@ -177,12 +159,7 @@ async function mainScript() {
}

// Start Docker healthcheck REST server on port set in config file
if (
(globals.config.has('Butler-SOS.dockerHealthCheck.enabled') &&
globals.config.get('Butler-SOS.dockerHealthCheck.enabled') === true) ||
(globals.config.has('Butler-SOS.dockerHealthCheck.enable') &&
globals.config.get('Butler-SOS.dockerHealthCheck.enable') === true)
) {
if (globals.config.get('Butler-SOS.dockerHealthCheck.enable') === true) {
try {
globals.logger.verbose('MAIN: Starting Docker healthcheck server...');

Expand All @@ -209,10 +186,7 @@ async function mainScript() {
}

// Start Prometheus metrics REST server on port set in config file
if (
globals.config.has('Butler-SOS.prometheus.enable') &&
globals.config.get('Butler-SOS.prometheus.enable') === true
) {
if (globals.config.get('Butler-SOS.prometheus.enable') === true) {
const promHost = globals.config.has('Butler-SOS.prometheus.host')
? globals.config.get('Butler-SOS.prometheus.host')
: '0.0.0.0';
Expand Down Expand Up @@ -254,12 +228,7 @@ async function mainScript() {
}

// Set up extraction of data from log db
if (
(globals.config.has('Butler-SOS.logdb.enableLogDb') &&
globals.config.get('Butler-SOS.logdb.enableLogDb') === true) ||
(globals.config.has('Butler-SOS.logdb.enable') &&
globals.config.get('Butler-SOS.logdb.enable') === true)
) {
if (globals.config.get('Butler-SOS.logdb.enable') === true) {
logDb.setupLogDbTimer();
}

Expand Down
12 changes: 2 additions & 10 deletions src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,7 @@ function initInfluxDB() {
const dbName = config.get('Butler-SOS.influxdbConfig.v1Config.dbName');
let enableInfluxdb = false;

if (
(config.has('Butler-SOS.influxdbConfig.enableInfluxdb') &&
config.get('Butler-SOS.influxdbConfig.enableInfluxdb') === true) ||
(config.has('Butler-SOS.influxdbConfig.enable') &&
config.get('Butler-SOS.influxdbConfig.enable') === true)
) {
if (config.get('Butler-SOS.influxdbConfig.enable') === true) {
enableInfluxdb = true;
}

Expand Down Expand Up @@ -558,10 +553,7 @@ function initInfluxDB() {
// ------------------------------------
let mqttClient;

if (
config.has('Butler-SOS.mqttConfig.enable') &&
config.get('Butler-SOS.mqttConfig.enable') === true
) {
if (config.get('Butler-SOS.mqttConfig.enable') === true) {
mqttClient = mqtt.connect({
port: config.get('Butler-SOS.mqttConfig.brokerPort'),
host: config.get('Butler-SOS.mqttConfig.brokerHost'),
Expand Down

0 comments on commit 1d6989e

Please sign in to comment.