diff --git a/src/client/grpc-manager.ts b/src/client/grpc-manager.ts index b1a7ff9a..17623745 100644 --- a/src/client/grpc-manager.ts +++ b/src/client/grpc-manager.ts @@ -61,6 +61,7 @@ class GrpcManager extends EventEmitter { protected _client? : puppet.PuppetClient get client () : puppet.PuppetClient { if (!this._client) { + this.emit('error', 'NO CLIENT') throw new Error('NO CLIENT') } return this._client diff --git a/src/client/puppet-service.ts b/src/client/puppet-service.ts index 3bef51a1..87abe8b9 100644 --- a/src/client/puppet-service.ts +++ b/src/client/puppet-service.ts @@ -97,6 +97,7 @@ class PuppetService extends PUPPET.Puppet { protected _grpcManager?: GrpcManager get grpcManager (): GrpcManager { if (!this._grpcManager) { + this.emit('error', 'no grpc manager') throw new Error('no grpc manager') } return this._grpcManager @@ -173,6 +174,9 @@ class PuppetService extends PUPPET.Puppet { await grpcManager.start() log.verbose('PuppetService', 'start() starting grpc manager... done') + log.verbose('PuppetService', 'start healthCheck') + this.startHealthCheck() + /** * Ducks management */ @@ -201,6 +205,8 @@ class PuppetService extends PUPPET.Puppet { } log.verbose('PuppetService', 'onStop() ... done') + log.verbose('PuppetService', 'stop healthCheck') + this.stopHealthCheck() } protected hookPayloadStore (): void { @@ -1984,6 +1990,17 @@ class PuppetService extends PUPPET.Puppet { } } + healthCheckInterval?: NodeJS.Timer + startHealthCheck () { + this.healthCheckInterval = setInterval(() => { + this.ding('healthCheck') + }, 60 * 1000) + } + + stopHealthCheck () { + clearInterval(this.healthCheckInterval!) + } + } export {