From f94814101b85721959d3cab0a705eff79d1c962c Mon Sep 17 00:00:00 2001 From: Heiko Rothe Date: Wed, 26 May 2021 22:14:10 +0200 Subject: [PATCH] fix: remove confusing error logs for optional deps --- .../thermopile/thermopile-occupancy.service.ts | 5 ----- src/status/health-indicator.service.ts | 15 ++++++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/integration-support/thermopile/thermopile-occupancy.service.ts b/src/integration-support/thermopile/thermopile-occupancy.service.ts index 0a20a70..2d7e687 100644 --- a/src/integration-support/thermopile/thermopile-occupancy.service.ts +++ b/src/integration-support/thermopile/thermopile-occupancy.service.ts @@ -4,7 +4,6 @@ import { Cluster } from './cluster'; import * as _ from 'lodash'; import { HeatmapOptions } from './thermopile-occupancy.config'; import { rotate } from '2d-array-rotation'; -import { Logger } from '@nestjs/common'; import type { createCanvas, Canvas, CanvasRenderingContext2D } from 'canvas'; export type RotationOption = 0 | 90 | 180 | 270; @@ -13,10 +12,6 @@ let nodeCanvas: { createCanvas: typeof createCanvas }; try { nodeCanvas = require('canvas'); } catch (e) { - Logger.debug( - `Could not load canvas: ${e.message}`, - 'ThermopileOccupancyService' - ); nodeCanvas = undefined; } diff --git a/src/status/health-indicator.service.ts b/src/status/health-indicator.service.ts index 095fe3a..887d86b 100644 --- a/src/status/health-indicator.service.ts +++ b/src/status/health-indicator.service.ts @@ -15,16 +15,15 @@ let notify; try { notify = require('sd-notify'); } catch (e) { - Logger.debug( - `Could not load sd-notify: ${e.message}`, - 'HealthIndicatorService' - ); + notify = undefined; } @Injectable() export class HealthIndicatorService - implements OnApplicationBootstrap, OnModuleDestroy { + implements OnApplicationBootstrap, OnModuleDestroy +{ private healthIndicators: HealthIndicatorFunction[] = []; + private readonly logger: Logger = new Logger(HealthIndicatorService.name); constructor( private readonly health: HealthCheckService, @@ -35,6 +34,12 @@ export class HealthIndicatorService * Lifecycle hook, called once the application has started. */ onApplicationBootstrap(): void { + if (notify == undefined) { + this.logger.debug( + 'Systemd watchdog reporting is unavailable, as the optional sd-notify dependency could not be loaded' + ); + } + notify?.ready(); const watchdogInterval: number = notify?.watchdogInterval();