Skip to content

Commit

Permalink
bf: crash lifecycle consumer when unable to connect with kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomoguiulfo committed Jun 8, 2018
1 parent 22282ac commit 3c890f5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion extensions/lifecycle/lifecycleConsumer/LifecycleConsumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class LifecycleConsumer extends EventEmitter {
* @return {undefined}
*/
start() {
let consumerReady = false;
this._consumer = new BackbeatConsumer({
zookeeper: {
connectionString: this.zkConfig.connectionString,
Expand All @@ -77,8 +78,14 @@ class LifecycleConsumer extends EventEmitter {
autoCommit: true,
backlogMetrics: this.lcConfig.backlogMetrics,
});
this._consumer.on('error', () => {});
this._consumer.on('error', () => {
if (!consumerReady) {
this.logger.fatal('error starting lifecycle consumer');
process.exit(1);
}
});
this._consumer.on('ready', () => {
consumerReady = true;
this._consumer.subscribe();
this.logger.info('lifecycle consumer successfully started');
return this.emit('ready');
Expand Down

0 comments on commit 3c890f5

Please sign in to comment.