You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2018/04/23 16:13:53 UTC
[incubator-openwhisk-package-cloudant] branch master updated: swap
active host on sigterm signal if host being stopped is currently active
(#169)
This is an automated email from the ASF dual-hosted git repository.
csantanapr 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 017a0f0 swap active host on sigterm signal if host being stopped is currently active (#169)
017a0f0 is described below
commit 017a0f0467956bfd41edfaeda5d7fb83174a0cdd
Author: Jason Peterson <ja...@us.ibm.com>
AuthorDate: Mon Apr 23 12:13:51 2018 -0400
swap active host on sigterm signal if host being stopped is currently active (#169)
---
provider/lib/utils.js | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/provider/lib/utils.js b/provider/lib/utils.js
index 3e38e1a..57550ca 100644
--- a/provider/lib/utils.js
+++ b/provider/lib/utils.js
@@ -460,7 +460,21 @@ module.exports = function(logger, triggerDB, redisClient) {
.then(activeHost => {
return utils.initActiveHost(activeHost);
})
- .then(resolve)
+ .then(() => {
+ process.on('SIGTERM', function onSigterm() {
+ if (utils.activeHost === utils.host) {
+ var redundantHost = utils.host === 'host0' ? 'host1' : 'host0';
+ utils.redisClient.hsetAsync(utils.redisHash, utils.redisKey, redundantHost)
+ .then(() => {
+ utils.redisClient.publish(utils.redisHash, redundantHost);
+ })
+ .catch(err => {
+ logger.error(method, err);
+ });
+ }
+ });
+ resolve();
+ })
.catch(err => {
reject(err);
});
--
To stop receiving notification emails like this one, please contact
csantanapr@apache.org.