mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-06-06 12:28:41 +02:00
Improve redis script
This commit is contained in:
@@ -11,7 +11,7 @@ if [[ -z "${REDIS_STATUS_KEY}" ]]; then
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi
|
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
|
if [ "${STATUS}" != 0 ] && [ "${STATUS}" != 1 ]; then
|
||||||
echo "Cound not set service status in Redis: ${STATUS}"
|
echo "Cound not set service status in Redis: ${STATUS}"
|
||||||
exit 1;
|
exit 1;
|
||||||
@@ -26,18 +26,12 @@ fi
|
|||||||
while true; do
|
while true; do
|
||||||
TIMESTAMP="$(date +%s%N)"
|
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})"
|
STATUS="$(redis-cli expire "${REDIS_STATUS_KEY}" ${EXPIRE_SECONDS})"
|
||||||
if [ "${STATUS}" != 1 ]; then
|
if [ "${STATUS}" != 1 ]; then
|
||||||
echo "Could not set status expire: ${STATUS}"
|
echo "Could not set status expire: ${STATUS}"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update heartbeat every 10 seconds.
|
# Update expire every 10 seconds.
|
||||||
sleep "${STATUS_INTERVAL_SECONDS}"
|
sleep "${STATUS_INTERVAL_SECONDS}"
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user