Skip to content

Commit

Permalink
Remove tegola process when there are more than x number
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Aug 17, 2023
1 parent 0c879ce commit d71be2c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions images/tiler-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ COPY ./expire-watcher.sh .
COPY ./seed-by-diffs.sh .
COPY ./tile_cache_downloader.sh .
COPY ./cache_cleaner.sh .
COPY ./rm_tegola_ps.sh .
# CMD ./start.sh & ./tile_cache_downloader.sh & ./expire-watcher.sh
4 changes: 2 additions & 2 deletions images/tiler-server/cache_cleaner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ flag=true
while "$flag" = true; do
pg_isready -h $POSTGRES_HOST -p 5432 >/dev/null 2>&2 || continue
flag=false
./tile_cache_downloader.sh & ./expire-watcher.sh
done
./tile_cache_downloader.sh & ./expire-watcher.sh & ./rm_tegola_ps.sh
done
15 changes: 15 additions & 0 deletions images/tiler-server/rm_tegola_ps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e
if [[ -n "${CLEAN_CACHE_MANUALLY}" && "${CLEAN_CACHE_MANUALLY}" == "true" && "${TILER_CACHE_TYPE}" && "${TILER_CACHE_TYPE}" == "s3" ]]; then
while true; do
NUM_PS_TEGOLA=$(ps | grep ${CACHE_PROCESS_NAME} | grep -v grep | wc -l)
if [[ $NUM_PS_TEGOLA -gt $MAX_PS_TEGOLA ]]; then
aws s3 rm s3://${TILER_CACHE_BUCKET}/mnt/data/osm/ --recursive
echo "${CACHE_PROCESS_NAME} processes"
ps aux | grep ${CACHE_PROCESS_NAME} | grep -v grep
# After clearing the S3 cache, terminate all 'tegola' processes.
killall ${CACHE_PROCESS_NAME}
fi
sleep 600
done
fi

0 comments on commit d71be2c

Please sign in to comment.