Add entry point and redis config + status to base container

This commit is contained in:
2021-07-21 17:30:46 +02:00
parent 088995adbc
commit 5c258512cf
3 changed files with 68 additions and 0 deletions
+7
View File
@@ -15,3 +15,10 @@ RUN wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.0/sr
ln -v -s `pwd`/hdf5/lib/* /usr/lib64/ && \
ln -v -s `pwd`/hdf5/include/* /usr/include/ && \
ln -v -s /usr/include/mpich-x86_64/* /usr/include/
COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
COPY redis_status.sh /usr/bin/redis_status.sh
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
CMD["bash"]
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
set -e
if [[ -z "${PIPELINE_NAME}" ]]; then
echo "Environment variable PIPELINE_NAME not defined."
exit 1;
fi
if [[ -z "${SERVICE_NAME}" ]]; then
echo "Environment variable SERVICE_NAME not defined."
exit 1;
fi
REDIS_HOST="${REDIS_HOST:-127.0.0.1}"
REDIS_SKIP="${REDIS_SKIP:-false}"
REDIS_CONFIG_KEY=config."${PIPELINE_NAME}"
REDIS_STATUS_KEY=status."${PIPELINE_NAME}.${SERVICE_NAME}"
# Download config from Redis to redis_config.json and start status reporting.
if [ "${REDIS_SKIP}" = false ]; then
redis-cli -h "${REDIS_HOST}" get "${REDIS_CONFIG_KEY}" > redis_config.json
CONFIG_BYTES="$(stat -c %s redis_config.json)"
if [ "${CONFIG_BYTES}" -le 1 ]; then
echo "Key missing in redis(${REDIS_HOST}): ${REDIS_CONFIG_KEY}"
exit 1;
fi
export REDIS_STATUS_KEY
redis_status.sh &
fi
EXECUTABLE="${@:1}"
exec "$EXECUTABLE"
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
set -e
if [[ -z "${REDIS_STATUS_KEY}" ]]; then
echo "Environment variable REDIS_STATUS_KEY not defined."
exit 1;
fi
STATUS="$(redis-cli -x set "${REDIS_STATUS_KEY}:config" < redis_config.json)"
if [ ! "${STATUS}" = "OK" ]; then
echo "Cound not set service status in Redis: ${STATUS}"
exit 1;
fi
while true; do
TIMESTAMP="$(date +%s%N)"
STATUS="$(redis-cli set "${REDIS_STATUS_KEY}:heartbeat" ${TIMESTAMP} )"
if [ ! "${STATUS}" = "OK" ]; then
echo "Cound not set service hearbeat in Redis: ${STATUS}"
exit 1;
fi
# Update heartbeat every 10 seconds.
sleep 10
done