From 240eb3abce04ec9bdddf168196e634a9fcf76e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Tue, 24 Jul 2018 23:30:18 +0200 Subject: [PATCH] [Netfilter] Wait for Redis instead of exiting with an exception --- data/Dockerfiles/netfilter/server.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/data/Dockerfiles/netfilter/server.py b/data/Dockerfiles/netfilter/server.py index 47c7539e..9bf4a084 100644 --- a/data/Dockerfiles/netfilter/server.py +++ b/data/Dockerfiles/netfilter/server.py @@ -14,7 +14,16 @@ import time import json import iptc -r = redis.StrictRedis(host=os.getenv('IPV4_NETWORK', '172.22.1') + '.249', decode_responses=True, port=6379, db=0) +while True: + try: + r = redis.StrictRedis(host=os.getenv('IPV4_NETWORK', '172.22.1') + '.249', decode_responses=True, port=6379, db=0) + r.ping() + except Exception as ex: + print '%s - trying again in 3 seconds' % (ex) + time.sleep(3) + else: + break + pubsub = r.pubsub() RULES = {}