diff --git a/data_handler/Containerfile b/data_handler/Containerfile index 633e712..342ae74 100644 --- a/data_handler/Containerfile +++ b/data_handler/Containerfile @@ -5,4 +5,4 @@ COPY ./data_init/*.sql /opt/init/init.sql ENTRYPOINT ["/opt/entrypoint.sh"] -CMD ["/bin/sh", "-c", "/usr/sbin/dcrond -f -d 5 > /var/log/dcrond.log 2>&1"] \ No newline at end of file +CMD ["/usr/sbin/dcrond", "-f" ] \ No newline at end of file diff --git a/data_handler/utils/entrypoint.sh b/data_handler/utils/entrypoint.sh index 9e726e8..c4dc346 100755 --- a/data_handler/utils/entrypoint.sh +++ b/data_handler/utils/entrypoint.sh @@ -8,7 +8,7 @@ set -e cat<> /var/log/update_camera_$(date +\%Y\%m\%d\%H\%M\%S).log 2>&1 +5 * * * * sh /opt/update_camera.sh EOF #################################################################################################### @@ -20,15 +20,7 @@ php /opt/init_db.php echo "Prescripts done" #################################################################################################### -### 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 +### Run cmd #################################################################################################### # see: https://github.com/dubiousjim/dcron/issues/13 diff --git a/data_handler/utils/update_camera.sh b/data_handler/utils/update_camera.sh index 4107d9f..25d23c8 100644 --- a/data_handler/utils/update_camera.sh +++ b/data_handler/utils/update_camera.sh @@ -63,7 +63,7 @@ do rm "change_file.osc.gz" fi - echo `date "+%d/%m/%Y %H:%M"`" - Start processing sequence number $curSeqNum of $newSeqNum" > "$logFileName" + echo `date "+%d/%m/%Y %H:%M"`" - Start processing sequence number $curSeqNum" > "$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 of $newSeqNum" | tee -a "$logFileName" + echo `date "+%d/%m/%Y %H:%M"`" - Finish processing sequence number $curSeqNum" | tee -a "$logFileName" done rm "/var/lock/update_camera" diff --git a/docker-compose.yml b/docker-compose.yml index 0224ddf..4509256 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,6 @@ services: db: image: mariadb:12.0.2 - restart: unless-stopped command: --max_allowed_packet=3250585600 environment: MYSQL_ROOT_PASSWORD: rootpassword # ${{secrets.MYSQL_ROOT_PASSWORD}} @@ -19,7 +18,6 @@ services: web: image: git.hamburg.ccc.de/ccchh/sunders/web:latest - restart: unless-stopped environment: MYSQL_HOST: db MYSQL_DB: camera # ${{secrets.MYSQL_DATABASE}} @@ -31,22 +29,13 @@ services: DEFAULT_LANGUAGE: en IMPRESSUM_URL: https://hamburg.ccc.de/imprint/ ports: - - "8081:80" + - "8080: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}} @@ -60,13 +49,6 @@ 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: \ No newline at end of file diff --git a/home/sunders/update_cameras/update_camera.sh b/home/sunders/update_cameras/update_camera.sh index b6d3338..b605ee4 100644 --- a/home/sunders/update_cameras/update_camera.sh +++ b/home/sunders/update_cameras/update_camera.sh @@ -60,7 +60,7 @@ do rm "change_file.osc.gz" fi - echo `date "+%d/%m/%Y %H:%M"`" - Start processing sequence number $curSeqNum of $newSeqNum" > "$logFileName" + echo `date "+%d/%m/%Y %H:%M"`" - Start processing sequence number $curSeqNum" > "$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 of $newSeqNum" | tee -a "$logFileName" + echo `date "+%d/%m/%Y %H:%M"`" - Finish processing sequence number $curSeqNum" | tee -a "$logFileName" done rm "/var/lock/update_camera"