Skip to content

Commit 34f5aa8

Browse files
jophalsjdamerow
andauthored
[Bug/gh-71] We need to make sure cron job starts after django app (#72)
* [bug/gh-71] attempted to fix by pinging website but unable to find solution; temporary fix implemented by waiting a fixed amount of time * [bug/gh-71] implemented loop that continuously pings eDrop until it responds successfully * [bug/gh-71] made pinging host and port configurable * [bug/gh-71] set priorty of gunicorn process ahead of cron job * [bug-gh-71] modified netcat loop to a curl loop * [gh-17] added a comment explaining the script change * [gh-71] we don't need to install netcat --------- Co-authored-by: Julia Damerow <[email protected]>
1 parent f560983 commit 34f5aa8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

edrop-cron.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,21 @@ export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
1515
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
1616
mkdir -p /edrop/logs
1717

18+
# When a new container is being created, eDROP Connector takes a long time to startup because all dependencies
19+
# need to be installed first. The cron job, however, needs all dependencies to be installed before it can start up.
20+
# Since we know that once eDROP Connector is up and running, all dependencies are installed, we just wait till we
21+
# get a 200 response from the web app before starting the cron job.
22+
# Using the autorestart property of Supervisor does not seem to work when deployed in production, hence this work around.
23+
while true; do
24+
sleep 5;
25+
http_response=$(curl -s -o /dev/null -I -w "%{http_code}\n" http://localhost:8000/$APP_ROOT);
26+
if [ $http_response == "200" ]; then
27+
break
28+
else
29+
echo "eDROP Connector is not yet responding."
30+
fi
31+
done
32+
echo "eDROP Connector has started successfully"
33+
1834
# start the cron job
1935
python manage.py runapscheduler

supervisord.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ stopasgroup=true
2222

2323
; if rabbitmq is supervised, set its priority higher
2424
; so it starts first
25-
priority=998
25+
priority=997
2626

2727
[program:edrop-cron]
2828
command=/edrop/edrop-cron.sh

0 commit comments

Comments
 (0)