Handle deleting conf files when subscribed
diff --git a/api-gateway-config/scripts/lua/lib/redis.lua b/api-gateway-config/scripts/lua/lib/redis.lua
index b28fa8d..b002b9a 100644
--- a/api-gateway-config/scripts/lua/lib/redis.lua
+++ b/api-gateway-config/scripts/lua/lib/redis.lua
@@ -203,6 +203,7 @@
         ngx.say("Subscribe error: ", err)
         ngx.exit(ngx.status)
     end
+
     ngx.say("Subscribed to redis and listening for key changes...")
     ngx.flush(true)
 
@@ -241,10 +242,17 @@
             end
 
             local routeObj = _M.getRoute(redisGetClient, redisKey, "route", ngx)
-            filemgmt.createRouteConf(BASE_CONF_DIR, namespace, ngx.escape_uri(gatewayPath), routeObj)
 
-            ngx.say(utils.concatStrings({redisKey, " updated"}))
-            ngx.log(ngx.INFO, utils.concatStrings({redisKey, " updated"}))
+            if routeObj == nil then
+                filemgmt.deleteRouteConf(BASE_CONF_DIR, namespace, ngx.escape_uri(gatewayPath))
+                ngx.say(utils.concatStrings({redisKey, " deleted"}))
+                ngx.log(ngx.INFO, utils.concatStrings({redisKey, " deleted"}))
+            else
+                filemgmt.createRouteConf(BASE_CONF_DIR, namespace, ngx.escape_uri(gatewayPath), routeObj)
+                ngx.say(utils.concatStrings({redisKey, " updated"}))
+                ngx.log(ngx.INFO, utils.concatStrings({redisKey, " updated"}))
+            end
+
             ngx.flush(true)
         end
     end
@@ -263,7 +271,6 @@
 
     _M.close(red, ngx)
 
-    subscribed = false
     ngx.say("Unsubscribed from redis")
     ngx.exit(ngx.status)
 end