Compare commits

...

5 commits

Author SHA1 Message Date
82b41342fc
fix: Restarts any container unless stopped by user
Some checks failed
images.yml / fix: Restarts any container unless stopped by user (pull_request) Has been cancelled
images.yml / fix: Restarts any container unless stopped by user (push) Has been cancelled
2025-10-25 21:22:23 +02:00
73e9c279df
feat: Adds healthcheck that restarts data_handler, when any error is printed to log files 2025-10-25 21:21:06 +02:00
f94080f45f
chore: Immediately starts update_camera on container startup 2025-10-25 21:20:27 +02:00
58f048adba
refactor: Increases verbosity of data_handler 2025-10-25 21:20:09 +02:00
fd6b1d680c
feat: Adds healthcheck to web server 2025-10-25 19:49:34 +02:00
5 changed files with 34 additions and 8 deletions

View file

@ -5,4 +5,4 @@ COPY ./data_init/*.sql /opt/init/init.sql
ENTRYPOINT ["/opt/entrypoint.sh"]
CMD ["/usr/sbin/dcrond", "-f" ]
CMD ["/bin/sh", "-c", "/usr/sbin/dcrond -f -d 5 > /var/log/dcrond.log 2>&1"]

View file

@ -8,7 +8,7 @@ set -e
cat<<EOF | dcrontab -
# min hour day month weekday command
5 * * * * sh /opt/update_camera.sh
*/15 * * * * sh /opt/update_camera.sh >> /var/log/update_camera_$(date +\%Y\%m\%d\%H\%M\%S).log 2>&1
EOF
####################################################################################################
@ -20,7 +20,15 @@ php /opt/init_db.php
echo "Prescripts done"
####################################################################################################
### Run cmd
### Run script once immediately
####################################################################################################
echo "Running update once initially..."
sh /opt/update_camera.sh >> /var/log/update_camera_$(date +\%Y\%m\%d\%H\%M\%S).log 2>&1
echo "Initial update done"
####################################################################################################
### Run cron to schedule periodic task
####################################################################################################
# see: https://github.com/dubiousjim/dcron/issues/13

View file

@ -63,7 +63,7 @@ do
rm "change_file.osc.gz"
fi
echo `date "+%d/%m/%Y %H:%M"`" - Start processing sequence number $curSeqNum" > "$logFileName"
echo `date "+%d/%m/%Y %H:%M"`" - Start processing sequence number $curSeqNum of $newSeqNum" > "$logFileName"
targetDirName=`echo "000000000$curSeqNum" | sed 's#.*\(...\)\(...\)\(...\)$#\1/\2/\3.osc.gz#'`
targetDirName="$REPLICATE_URL/$targetDirName"
@ -87,7 +87,7 @@ do
targetDirName=`echo "$targetDirName" | sed 's/.osc.gz$/.state.txt/'`
curl -L "$targetDirName" -o lastState.txt 2>&1 | tee -a $logFileName
echo `date "+%d/%m/%Y %H:%M"`" - Finish processing sequence number $curSeqNum" | tee -a "$logFileName"
echo `date "+%d/%m/%Y %H:%M"`" - Finish processing sequence number $curSeqNum of $newSeqNum" | tee -a "$logFileName"
done
rm "/var/lock/update_camera"

View file

@ -1,6 +1,7 @@
services:
db:
image: mariadb:12.0.2
restart: unless-stopped
command: --max_allowed_packet=3250585600
environment:
MYSQL_ROOT_PASSWORD: rootpassword # ${{secrets.MYSQL_ROOT_PASSWORD}}
@ -18,6 +19,7 @@ services:
web:
image: git.hamburg.ccc.de/ccchh/sunders/web:latest
restart: unless-stopped
environment:
MYSQL_HOST: db
MYSQL_DB: camera # ${{secrets.MYSQL_DATABASE}}
@ -29,13 +31,22 @@ services:
DEFAULT_LANGUAGE: en
IMPRESSUM_URL: https://hamburg.ccc.de/imprint/
ports:
- "8080:80"
- "8081:80"
depends_on:
data_handler:
condition: service_started
# all the way zoomed out, with hamburg at the center, at least one camera should be returned
healthcheck:
test: >
["CMD", "curl -s 'http://localhost/camera.php?bbox=-92.52991540527346,30.683278176916133,131.7689595947266,72.87186315234298&zoom=4&width=2552&height=867' | grep '^\[.+\]$'"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 5
data_handler:
image: git.hamburg.ccc.de/ccchh/sunders/data_handler:latest
restart: unless-stopped
environment:
MYSQL_HOST: db
MYSQL_DB: camera # ${{secrets.MYSQL_DATABASE}}
@ -49,6 +60,13 @@ services:
db:
condition: service_healthy
restart: true
# if the latest `update_camera_*.log` contains "error", fail the healthcheck
healthcheck:
test: ["CMD", "sh", "-c", "ls /var/log | grep '^update_camera_' | xargs -I {} sh -c 'grep -q error /var/log/{} || exit 0; exit 1'"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 5
volumes:
mariadb:

View file

@ -60,7 +60,7 @@ do
rm "change_file.osc.gz"
fi
echo `date "+%d/%m/%Y %H:%M"`" - Start processing sequence number $curSeqNum" > "$logFileName"
echo `date "+%d/%m/%Y %H:%M"`" - Start processing sequence number $curSeqNum of $newSeqNum" > "$logFileName"
targetDirName=`echo "000000000$curSeqNum" | sed 's#.*\(...\)\(...\)\(...\)$#\1/\2/\3.osc.gz#'`
targetDirName="$REPLICATE_URL/$targetDirName"
@ -84,7 +84,7 @@ do
targetDirName=`echo "$targetDirName" | sed 's/.osc.gz$/.state.txt/'`
wget -nv "$targetDirName" -O lastState.txt 2>&1 | tee -a $logFileName
echo `date "+%d/%m/%Y %H:%M"`" - Finish processing sequence number $curSeqNum" | tee -a "$logFileName"
echo `date "+%d/%m/%Y %H:%M"`" - Finish processing sequence number $curSeqNum of $newSeqNum" | tee -a "$logFileName"
done
rm "/var/lock/update_camera"