mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-20 13:54:36 +02:00
Improve redis script
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user