forked from kamba4/sunders
Compare commits
5 commits
9138d57429
...
82b41342fc
| Author | SHA1 | Date | |
|---|---|---|---|
|
82b41342fc |
|||
|
73e9c279df |
|||
|
f94080f45f |
|||
|
58f048adba |
|||
|
fd6b1d680c |
5 changed files with 34 additions and 8 deletions
|
|
@ -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"]
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue