Skip to content

Commit 98cc898

Browse files
committed
Wait less for instance-cron to be up
1 parent 9bb1b60 commit 98cc898

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

docker/docker-entrypoint.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,25 @@ function setup() {
1515
fi
1616
}
1717
function wait_for_cron() {
18-
CURL="curl --write-out '%{http_code}' -so /dev/null worker-cron:8087/$PLONE_PATH/@@ok"
19-
echo "Waiting instance-cron ..."
20-
sleep 20
21-
response=$($CURL)
22-
echo "received response $response"
23-
while [[ "$response" != "'200'" ]]; do
24-
echo "Waiting instance-cron ..."
25-
sleep 10
18+
URL="worker-cron:8087/$PLONE_PATH"
19+
CURL="curl --write-out %{http_code} -so /dev/null $URL/@@ok"
20+
MAX_TRIES=240
21+
INTERVAL=1
22+
SECONDS=0
23+
response="$($CURL)"
24+
tries=1
25+
while [[ $response != "200" && $tries -lt $MAX_TRIES ]]
26+
do
27+
sleep $INTERVAL
2628
response=$($CURL)
27-
echo "received response $response"
29+
((tries+=1))
2830
done
31+
if [[ $tries == "$MAX_TRIES" ]]; then
32+
echo "Failed to reach $URL after $SECONDS s"
33+
exit 1
34+
else
35+
echo "$URL is up. Waited $SECONDS s"
36+
fi
2937
}
3038
function start() {
3139
echo "Starting $1"

0 commit comments

Comments
 (0)