This is an automated email from the ASF dual-hosted git repository. dubeejw pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-cloudant.git
The following commit(s) were added to refs/heads/master by this push: new 5d5da54 do not assume env var HOST_INDEX begins with 'host' (#174) 5d5da54 is described below commit 5d5da5405cd3a10868d95f5b00ae0d2b205f854f Author: Jason Peterson <jason...@us.ibm.com> AuthorDate: Wed May 9 14:18:24 2018 -0400 do not assume env var HOST_INDEX begins with 'host' (#174) --- provider/lib/active.js | 2 +- provider/lib/utils.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/provider/lib/active.js b/provider/lib/active.js index cbc5017..980473b 100644 --- a/provider/lib/active.js +++ b/provider/lib/active.js @@ -24,7 +24,7 @@ module.exports = function(logger, utils) { return; } - var redundantHost = utils.host === 'host0' ? 'host1' : 'host0'; + var redundantHost = utils.host === `${utils.hostPrefix}0` ? `${utils.hostPrefix}1` : `${utils.hostPrefix}0`; var activeHost = query === 'true' ? utils.host : redundantHost; if (utils.activeHost !== activeHost) { if (utils.redisClient) { diff --git a/provider/lib/utils.js b/provider/lib/utils.js index 1256d59..808beb4 100644 --- a/provider/lib/utils.js +++ b/provider/lib/utils.js @@ -16,7 +16,8 @@ module.exports = function(logger, triggerDB, redisClient) { this.routerHost = process.env.ROUTER_HOST || 'localhost'; this.worker = process.env.WORKER || 'worker0'; this.host = process.env.HOST_INDEX || 'host0'; - this.activeHost = 'host0'; //default value on init (will be updated for existing redis) + this.hostPrefix = this.host.replace(/\d+$/, ''); + this.activeHost = `${this.hostPrefix}0`; //default value on init (will be updated for existing redis) this.db = triggerDB; this.redisClient = redisClient; this.redisKey = redisKeyPrefix + '_' + this.worker; @@ -462,7 +463,7 @@ module.exports = function(logger, triggerDB, redisClient) { .then(() => { process.on('SIGTERM', function onSigterm() { if (self.activeHost === self.host) { - var redundantHost = self.host === 'host0' ? 'host1' : 'host0'; + var redundantHost = self.host === `${self.hostPrefix}0` ? `${self.hostPrefix}1` : `${self.hostPrefix}0`; self.redisClient.hsetAsync(self.redisKey, self.redisField, redundantHost) .then(() => { self.redisClient.publish(self.redisKey, redundantHost); -- To stop receiving notification emails like this one, please contact dube...@apache.org.