From ebaaedecd9d06fd129f904e7962c12dc04e1c8b6 Mon Sep 17 00:00:00 2001 From: nolash Date: Sat, 24 Apr 2021 10:35:52 +0200 Subject: [PATCH] Add omitted file --- apps/cic-eth/cic_eth/check/redis.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 apps/cic-eth/cic_eth/check/redis.py diff --git a/apps/cic-eth/cic_eth/check/redis.py b/apps/cic-eth/cic_eth/check/redis.py new file mode 100644 index 00000000..7a147fe9 --- /dev/null +++ b/apps/cic-eth/cic_eth/check/redis.py @@ -0,0 +1,18 @@ +# external imports +import redis +import os + + +def health(*args, **kwargs): + r = redis.Redis( + host=kwargs['config'].get('REDIS_HOST'), + port=kwargs['config'].get('REDIS_PORT'), + db=kwargs['config'].get('REDIS_DB'), + ) + try: + r.set(kwargs['unit'], os.getpid()) + except redis.connection.ConnectionError: + return False + except redis.connection.ResponseError: + return False + return True