Skip to content

Commit

Permalink
fix: remove confusing error logs for optional deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mKeRix committed May 26, 2021
1 parent 068a06e commit f948141
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
15 changes: 10 additions & 5 deletions src/status/health-indicator.service.ts
Expand Up @@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit f948141

Please sign in to comment.