Skip to content
Snippets Groups Projects
Verified Commit d78a0dd5 authored by egon w. stemle's avatar egon w. stemle :robot:
Browse files

Avoid tomcat start/kill/restart-cycle at startup

parent 3ee5825f
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Use dsapce-app image 2020.02.1:1.0
- Rm apt cache after apt-get update+install
- Rebuild Postgres image with latest 9.6
- Avoid tomcat start/kill/restart-cycle at startup
### Fixed
- #60
......
......@@ -15,44 +15,33 @@ perl -pi -e 's/\$\{HANDLE_USER\}/$ENV{HANDLE_USER}/; s/\$\{HANDLE_PASSWORD\}/$EN
# initialize statistics & co
cd /opt/repository/workspace/scripts
make init_statistics
/opt/tomcat8/bin/catalina.sh start
# wait for tomcat to start...
sleep 120
# https://ubuntuforums.org/showthread.php?t=979694
# Start process in the background and send its output to file descriptor 3
exec 3< <(while (true); do
set -x
LOGID=$(( (LOGID+1) % 5))
LOG="/tmp/entrypoint.log.$LOGID"
echo "$LOG" > $LOG
timeout -k 30 300 make update_oai | tee -a $LOG
timeout -k 30 300 make update_statistics | tee -a $LOG
timeout -k 30 300 make update_sitemap | tee -a $LOG
timeout -k 30 300 make lift_embargos | tee -a $LOG
timeout -k 30 300 make update_openaire_cache | tee -a $LOG
timeout -k 30 300 make update_discovery | tee -a $LOG
timeout -k 30 300 make send_info | tee -a $LOG
date >> $LOG
echo "INIT DONE."
wget https://healthchecks.local.iiegn.eu/ping/24a81cdc-2906-4faa-89b3-0d57541abef6 -T 10 -t 5 -O /dev/null
set +x
sleep 86400
done)
# Read the output of the process line by line until one line contains Ready
while read line; do
case "$line" in
"INIT DONE.")
break
;;
esac
done <&3
# Close the file descriptor
exec <&3 3<&-
/opt/tomcat8/bin/catalina.sh stop -force
# Start cron job in the background
cron_hack(){
INIT="false"
while (true); do
# the first time, wait for tomcat to start...
[ "$INIT" = "false" ] && sleep 300 && INIT="true"
set -x
LOGID=$(( (LOGID+1) % 5))
LOG="/tmp/entrypoint.log.$LOGID"
echo "$LOG" > $LOG
timeout -k 30 300 make update_oai | tee -a $LOG
timeout -k 30 300 make update_statistics | tee -a $LOG
timeout -k 30 300 make update_sitemap | tee -a $LOG
timeout -k 30 300 make lift_embargos | tee -a $LOG
timeout -k 30 300 make update_openaire_cache | tee -a $LOG
timeout -k 30 300 make update_discovery | tee -a $LOG
timeout -k 30 300 make send_info | tee -a $LOG
date >> $LOG
echo "INIT DONE."
wget https://healthchecks.local.iiegn.eu/ping/24a81cdc-2906-4faa-89b3-0d57541abef6 -T 10 -t 5 -O /dev/null
set +x
sleep 86400
done
}
cron_hack &
# start tomcat
/opt/tomcat8/bin/catalina.sh run
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment