csantanapr closed pull request #145: swap active host on sigterm signal if host being stopped is active URL: https://github.com/apache/incubator-openwhisk-package-alarms/pull/145
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 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); }); ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services