Skip to content

Commit

Permalink
fix(sms): not starting up with invalid config (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkopanidis committed Aug 26, 2022
1 parent b91104c commit eb57231
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions modules/sms/src/Sms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ export default class Sms extends ManagedModule<Config> {
this.updateHealth(HealthCheckStatus.NOT_SERVING);
} else {
await this.initProvider();
this.adminRouter.updateProvider(this._provider!);
this.isRunning = true;
this.updateHealth(HealthCheckStatus.SERVING);
}
}

Expand All @@ -81,11 +78,21 @@ export default class Sms extends ManagedModule<Config> {
const settings = smsConfig[name];

if (name === 'twilio') {
this._provider = new TwilioProvider(settings);
try {
this._provider = new TwilioProvider(settings);
} catch (e) {
this._provider = undefined;
this.updateHealth(HealthCheckStatus.NOT_SERVING);
ConduitGrpcSdk.Logger.error(e as Error);
return;
}
} else {
ConduitGrpcSdk.Logger.error('SMS provider not supported');
process.exit(-1);
return;
}
this.adminRouter.updateProvider(this._provider!);
this.isRunning = true;
this.updateHealth(HealthCheckStatus.SERVING);
}

// gRPC Service
Expand Down

0 comments on commit eb57231

Please sign in to comment.