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-alarms.git


The following commit(s) were added to refs/heads/master by this push:
     new e0ae88f  swap active host on sigterm signal if host being stopped is 
currently active (#145)
e0ae88f is described below

commit e0ae88f3be0bfbdbae3c6288a9f989c07cf74c4a
Author: Jason Peterson <[email protected]>
AuthorDate: Mon Apr 23 12:13:30 2018 -0400

    swap active host on sigterm signal if host being stopped is currently 
active (#145)
---
 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 3714b73..cceffab 100644
--- a/provider/lib/utils.js
+++ b/provider/lib/utils.js
@@ -466,7 +466,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
[email protected].

Reply via email to