From 85da98e4efc1f53feb0fb9800aae502e101f5d60 Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Thu, 22 Jul 2021 12:10:44 +0200 Subject: [PATCH] Improve redis script --- docker/redis_status.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/docker/redis_status.sh b/docker/redis_status.sh index 970914b..b115630 100755 --- a/docker/redis_status.sh +++ b/docker/redis_status.sh @@ -11,7 +11,7 @@ if [[ -z "${REDIS_STATUS_KEY}" ]]; then exit 1; fi -STATUS="$(redis-cli -x hset "${REDIS_STATUS_KEY} config" < redis_config.json)" +STATUS="$(redis-cli -x hset "${REDIS_STATUS_KEY}" config < redis_config.json)" if [ "${STATUS}" != 0 ] && [ "${STATUS}" != 1 ]; then echo "Cound not set service status in Redis: ${STATUS}" exit 1; @@ -26,18 +26,12 @@ fi while true; do TIMESTAMP="$(date +%s%N)" - STATUS="$(redis-cli hset "${REDIS_STATUS_KEY} heartbeat" "${TIMESTAMP}" )" - if [ ! "${STATUS}" = "OK" ]; then - echo "Cound not set service hearbeat in Redis: ${STATUS}" - exit 1; - fi - STATUS="$(redis-cli expire "${REDIS_STATUS_KEY}" ${EXPIRE_SECONDS})" if [ "${STATUS}" != 1 ]; then echo "Could not set status expire: ${STATUS}" exit 1; fi - # Update heartbeat every 10 seconds. + # Update expire every 10 seconds. sleep "${STATUS_INTERVAL_SECONDS}" done