Skip to content

Commit

Permalink
[OGUI-1557] Added Try Catch for kafkaclient (#2668)
Browse files Browse the repository at this point in the history
* Adds an extra layer of try-catch to ensure that if the KafkaClient initialization fails, we do not crash the server
  • Loading branch information
pepijndik authored Nov 21, 2024
1 parent 8ea76d3 commit 70ad3d3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Control/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,20 @@ module.exports.setup = (http, ws) => {

let aliEcsSynchronizer = undefined;
if (config.kafka && config.kafka?.enable) {
const kafkaClient = new Kafka({
clientId: 'control-gui',
brokers: config.kafka.brokers,
retry: { retries: 3 },
logLevel: logLevel.NOTHING,
});

aliEcsSynchronizer = new AliEcsSynchronizer(kafkaClient, cacheService);
aliEcsSynchronizer.start();
try {
const kafkaClient = new Kafka({
clientId: 'control-gui',
brokers: config.kafka.brokers,
retry: { retries: 3 },
logLevel: logLevel.NOTHING,
});
aliEcsSynchronizer = new AliEcsSynchronizer(kafkaClient, cacheService);
aliEcsSynchronizer.start();

} catch (error) {
logger.errorMessage(`Kafka initialization failed: ${error.message}`);
}

}

const statusService = new StatusService(
Expand Down

0 comments on commit 70ad3d3

Please sign in to comment.