Skip to content

Commit

Permalink
Update entrypoint.sh
Browse files Browse the repository at this point in the history
add check with dockerize exe, instead of my own
  • Loading branch information
feddar authored Nov 6, 2020
1 parent 6a672f5 commit 738b0d6
Showing 1 changed file with 10 additions and 39 deletions.
49 changes: 10 additions & 39 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,45 +82,16 @@ LOGFILE="/var/log/rspamd/rspamd.log"

[ ! -f $LOGFILE ] && touch $LOGFILE && chown _rspamd:_rspamd $LOGFILE

# Variable WAITFOR set as a space separated series of comma separated values
# i.e.: "my_clamav:clamav:3310
# 3rd parameter (port) can be omitted for default ports
check_service() {
until eval $1 ; do
sleep 1
echo -n "..."
done
echo -n "OK"
}
if [ -n "$WAITFOR" ]; then
for CHECK in $WAITFOR; do
IFS=':' read -a SERVICE <<< "$CHECK"
# while array: ${SERVICE[*]}
NAME="${SERVICE[0]}"
SRV="${SERVICE[1]}"
PORT="${SERVICE[2]}"
if [ -z "$NAME" -o -z "$SRV" ]; then
continue
fi
echo -n "Checking for service $SRV on $NAME..."
case "$SRV" in
"clamav")
PORT=${PORT:-3310}
check_service 'echo PING | nc -w 5 $NAME $PORT 2>/dev/null'
;;
"rspamd")
check_service 'ping -c1 $NAME 1>/dev/null 2>/dev/null'
;;
"redis")
PORT=${PORT:-6379}
check_service 'timeout 2 redis-cli -h $NAME -p $PORT PING'
;;
*)
check_service 'ping -c1 $NAME 1>/dev/null 2>/dev/null'
;;
esac
echo " "
done
cmd="/dockerize"
if [ -x "$cmd" ]; then
checks=""
if [ -n "$WAITFOR" ]; then
for CHECK in $WAITFOR; do
checks="$checks -wait $CHECK"
done
$cmd $checks -timeout 180s -wait-retry-interval 15s
[ $? -ne 0 ] && exit 1
fi
fi

exec tail -F $LOGFILE &
Expand Down

0 comments on commit 738b0d6

Please sign in to comment.