Skip to content

Commit

Permalink
Merge pull request #224 from OpenHistoricalMap/staging
Browse files Browse the repository at this point in the history
Remove tiler cache manually when container gets too busy.
  • Loading branch information
Ruben L. Mendoza authored Aug 17, 2023
2 parents 20a2f68 + 130a979 commit 6d5a620
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 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
16 changes: 16 additions & 0 deletions images/tiler-server/rm_tegola_ps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e
if [[ -n "${KILL_PROCESS}" && "${KILL_PROCESS}" == "manually" ]]; then
while true; do
NUM_PS=$(ps | grep ${PROCESS_NAME} | grep -v grep | wc -l)
if [[ $NUM_PS -gt $MAX_NUM_PS ]]; then
echo "${PROCESS_NAME} processes"
ps aux | grep ${PROCESS_NAME} | grep -v grep
# After clearing the S3 cache, terminate all 'tegola' processes.
killall ${PROCESS_NAME}
# Clean cache manually from s3
aws s3 rm s3://${TILER_CACHE_BUCKET}/mnt/data/osm/ --recursive
fi
sleep 600
done
fi
2 changes: 1 addition & 1 deletion ohm/requirements.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dependencies:
- name: osm-seed
version: '0.1.0-n771.h5ab71b9'
version: '0.1.0-n768.h455eb76'
repository: https://devseed.com/osm-seed-chart/
10 changes: 7 additions & 3 deletions values.production.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,15 @@ osm-seed:
limits:
memory: "10Gi"
cpu: "2"
env:
KILL_PROCESS: manually
MAX_NUM_PS: 5
PROCESS_NAME: tegola
autoscaling:
enabled: false
enabled: true
minReplicas: 1
maxReplicas: 2
cpuUtilization: 60
maxReplicas: 1
cpuUtilization: 90
# ====================================================================================================
# Variables for tiler-visor
# ====================================================================================================
Expand Down
10 changes: 7 additions & 3 deletions values.staging.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,15 @@ osm-seed:
limits:
memory: "10Gi"
cpu: "2"
env:
KILL_PROCESS: manually
MAX_NUM_PS: 4
PROCESS_NAME: tegola
autoscaling:
enabled: false
enabled: true
minReplicas: 1
maxReplicas: 2
cpuUtilization: 60
maxReplicas: 1
cpuUtilization: 90
# ====================================================================================================
# Variables for tiler-visor
# ====================================================================================================
Expand Down

0 comments on commit 6d5a620

Please sign in to comment.