Improve redis script

This commit is contained in:
2021-07-22 12:10:44 +02:00
parent 54bf7bf895
commit 85da98e4ef
+2 -8
View File
@@ -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