swap active host on sigterm signal if host being stopped is currently active (#145)

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