From 3c890f522544222ac3f2dbb979b2d0bbaff1c468 Mon Sep 17 00:00:00 2001 From: Giacomo Guiulfo Date: Fri, 8 Jun 2018 16:28:10 -0700 Subject: [PATCH] bf: crash lifecycle consumer when unable to connect with kafka --- .../lifecycle/lifecycleConsumer/LifecycleConsumer.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/lifecycle/lifecycleConsumer/LifecycleConsumer.js b/extensions/lifecycle/lifecycleConsumer/LifecycleConsumer.js index 5bcf71ab5..2b82c953c 100644 --- a/extensions/lifecycle/lifecycleConsumer/LifecycleConsumer.js +++ b/extensions/lifecycle/lifecycleConsumer/LifecycleConsumer.js @@ -65,6 +65,7 @@ class LifecycleConsumer extends EventEmitter { * @return {undefined} */ start() { + let consumerReady = false; this._consumer = new BackbeatConsumer({ zookeeper: { connectionString: this.zkConfig.connectionString, @@ -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');