Skip to content

Commit

Permalink
fix(winsvc): Win service monitoring no longer rely on New Relic
Browse files Browse the repository at this point in the history
Fixes #967
  • Loading branch information
Göran Sander committed Feb 1, 2024
1 parent 4ca297c commit e47124c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/butler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ const start = async () => {
// Load globals dynamically/async to ensure singleton pattern works
const settingsObj = (await import('./globals.js')).default;
const globals = await settingsObj.init();
console.log(`globals initialised`);
console.log(`globals.initialised: ${globals.initialised}`);
globals.logger.verbose('MAIN: Globals initialised.');
globals.logger.verbose(`START: Globals init done: ${globals.initialised}`);

const setupServiceMonitorTimer = (await import('./lib/service_monitor.js')).default;

Expand Down
2 changes: 1 addition & 1 deletion src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ class Settings {
// Indicate that we have finished initialising
this.initialised = true;

console.log('globals init done');
this.logger.verbose('GLOBALS: Init done');

// eslint-disable-next-line no-constructor-return
return instance;
Expand Down
16 changes: 6 additions & 10 deletions src/lib/service_monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,7 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => {

// Get details about this service
const serviceDetails = await details(logger, service.name, host.host);
if (
serviceStatus === 'STOPPED' &&
config.has('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.stopped.enable') &&
config.get('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.stopped.enable') === true
) {
if (serviceStatus === 'STOPPED') {
logger.warn(`Service "${serviceDetails.displayName}" on host "${host.host}" is stopped`);

// Update state machine
Expand All @@ -235,6 +231,8 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => {

// New Relic
if (
config.has('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.stopped.enable') &&
config.get('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.stopped.enable') === true &&
config.has('Butler.serviceMonitor.alertDestination.newRelic.enable') &&
config.get('Butler.serviceMonitor.alertDestination.newRelic.enable') === true
) {
Expand Down Expand Up @@ -343,11 +341,7 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => {
});
}
}
} else if (
serviceStatus === 'RUNNING' &&
config.has('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.running.enable') &&
config.get('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.running.enable') === true
) {
} else if (serviceStatus === 'RUNNING') {
logger.verbose(`Service "${service.name}" is running`);

// Update state machine
Expand Down Expand Up @@ -377,6 +371,8 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => {

// New Relic
if (
config.has('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.running.enable') &&
config.get('Butler.incidentTool.newRelic.serviceMonitor.monitorServiceState.running.enable') === true &&
config.has('Butler.serviceMonitor.alertDestination.newRelic.enable') &&
config.get('Butler.serviceMonitor.alertDestination.newRelic.enable') === true
) {
Expand Down

0 comments on commit e47124c

Please sign in to comment.