Skip to content

Commit

Permalink
UHF-10354: Check cron pod failure codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrsky committed Aug 2, 2024
1 parent 08dc660 commit df8ca25
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
16 changes: 12 additions & 4 deletions docker/openshift/crons/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ echo "Starting cron: $(date)"
# done
# @endcode

# Enable drush cron
exec "/crons/cron.sh" &
# Uncomment this to enable TPR migration cron
#exec "/crons/migrate-tpr.sh" &
# Uncomment this to enable linked events migrations cron
Expand All @@ -31,8 +33,14 @@ echo "Starting cron: $(date)"

while true
do
echo "Running cron: $(date +'%Y-%m-%dT%H:%M:%S%:z')\n"
drush cron
# Sleep for 10 minutes.
sleep 600
# Rudimentary process supervisor:
# Waits for the next process to terminate. The parent
# process is killed if any subprocess exists with failure.
# OpenShift should then restart the cron pod.
wait -n
exit_code=$?
if [[ "$exit_code" -ne 0 ]]; then
output_error_message "Subprocess failed with exit code $exit_code"
exit 1
fi
done
9 changes: 9 additions & 0 deletions docker/openshift/crons/cron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

while true
do
echo "Running cron: $(date +'%Y-%m-%dT%H:%M:%S%:z')\n"
drush cron
# Sleep for 10 minutes.
sleep 600
done
13 changes: 4 additions & 9 deletions docker/openshift/crons/pubsub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@

echo "Running PubSub daemon: $(date +'%Y-%m-%dT%H:%M:%S%:z')"

i=0
# Attempt to start this service five times.
until [ $i -gt 5 ]
while true
do
drush helfi:azure:pubsub-listen

if [[ "$?" -ne 0 ]]; then
((i=i+1))
sleep 10
fi
# PubSub process exists with success return code after
# certain number of messages and should then be restarted.
drush helfi:azure:pubsub-listen || exit 1
done

0 comments on commit df8ca25

Please sign in to comment.