From f5d59d4c3456b261a7745e7ed737a6f2120e4ae3 Mon Sep 17 00:00:00 2001 From: Konstantinos Feretos Date: Thu, 18 May 2023 14:20:31 +0300 Subject: [PATCH 1/2] fix(sms): admin routes initialization before module registration error --- modules/sms/src/Sms.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/sms/src/Sms.ts b/modules/sms/src/Sms.ts index 251298c9d..cdfdd6184 100644 --- a/modules/sms/src/Sms.ts +++ b/modules/sms/src/Sms.ts @@ -42,10 +42,6 @@ export default class Sms extends ManagedModule { this.updateHealth(HealthCheckStatus.UNKNOWN, true); } - async onServerStart() { - this.adminRouter = new AdminHandlers(this.grpcServer, this.grpcSdk, this._provider); - } - async preConfig(config: any) { if ( isNil(config.active) || @@ -61,6 +57,7 @@ export default class Sms extends ManagedModule { if (!ConfigController.getInstance().config.active) { this.updateHealth(HealthCheckStatus.NOT_SERVING); } else { + this.adminRouter = new AdminHandlers(this.grpcServer, this.grpcSdk, this._provider); await this.initProvider(); } } From d62276b416c6e4c7f1887c14453471a5a4ff3139 Mon Sep 17 00:00:00 2001 From: Konstantinos Feretos Date: Thu, 18 May 2023 14:34:15 +0300 Subject: [PATCH 2/2] fix(functions): admin routes initialization before module registration error --- modules/functions/src/Functions.ts | 35 +++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/functions/src/Functions.ts b/modules/functions/src/Functions.ts index 3733d47e7..cab65dbda 100644 --- a/modules/functions/src/Functions.ts +++ b/modules/functions/src/Functions.ts @@ -27,27 +27,32 @@ export default class Functions extends ManagedModule { await this.grpcSdk.waitForExistence('database'); this.database = this.grpcSdk.database!; await this.registerSchemas(); - this.grpcSdk - .waitForExistence('router') - .then(() => { - this.isRunning = true; - this.functionsController = new FunctionController(this.grpcServer, this.grpcSdk); - this.adminRouter = new AdminHandlers( - this.grpcServer, - this.grpcSdk, - this.functionsController, - ); - return this.functionsController.refreshRoutes(); - }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e.message); - }); } async onConfig() { if (!ConfigController.getInstance().config.active) { this.updateHealth(HealthCheckStatus.NOT_SERVING); } + if (!this.isRunning) { + this.grpcSdk + .waitForExistence('router') + .then(() => { + this.isRunning = true; + this.functionsController = new FunctionController( + this.grpcServer, + this.grpcSdk, + ); + this.adminRouter = new AdminHandlers( + this.grpcServer, + this.grpcSdk, + this.functionsController, + ); + return this.functionsController.refreshRoutes(); + }) + .catch(e => { + ConduitGrpcSdk.Logger.error(e.message); + }); + } this.updateHealth(HealthCheckStatus.SERVING); }