You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/04/23 16:13:53 UTC

[GitHub] csantanapr closed pull request #169: swap active host on sigterm signal if host being stopped is active

csantanapr closed pull request #169: swap active host on sigterm signal if host being stopped is active
URL: https://github.com/apache/incubator-openwhisk-package-cloudant/pull/169
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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);
                 });


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services