From b4d111871d70c6f02e536d1e85a0dfa28404cbf1 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 15 Mar 2022 23:20:55 +0100 Subject: [PATCH] remove nginx prune script --- scripts/README.md | 6 ----- scripts/lib/nginx-prune-cache-subscript.sh | 30 ---------------------- scripts/nginx-prune.sh | 9 ------- setup-scripts/support/crontab | 1 - 4 files changed, 46 deletions(-) delete mode 100755 scripts/lib/nginx-prune-cache-subscript.sh delete mode 100755 scripts/nginx-prune.sh diff --git a/scripts/README.md b/scripts/README.md index 2085eff7..e7b909b4 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -29,12 +29,6 @@ the health check. The `portal-upgrade.sh` script upgrades the docker images for a portal and clears and leftover images. -**nginx-prune.sh**\ -The `nginx-prune.sh` script deletes all entries from nginx cache larger than -the given size and smaller entries until nginx cache disk size is smaller than -the given cache size limit. Both values are configured in -`lib/nginx-prune-cache-subscript.sh`. The script doesn't require `sudo`. - ## Webportal Upgrade Procedures TODO... diff --git a/scripts/lib/nginx-prune-cache-subscript.sh b/scripts/lib/nginx-prune-cache-subscript.sh deleted file mode 100755 index 99edb899..00000000 --- a/scripts/lib/nginx-prune-cache-subscript.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/local/bin/bash - -# This subscript is expected to be run inside docker container using 'bash' -# image. The image is based on Alpine Linux. It's tools (find, stat, awk, sort) -# are non-standard versions from BusyBox. - -MAX_CACHE_DIR_SIZE=20000000000 -MAX_KEEP_FILE_SIZE=1000000000 - -total=0 - -# We sort files by time, newest files are first. Format is: -# time (last modification as seconds since Epoch), filepath, size (bytes) -find /home/user/skynet-webportal/docker/data/nginx/cache -type f -exec stat -c "%Y %n %s" {} + | sort -rgk1 | while read line -do - size=$(echo $line | awk '{print $3}') - new_total=$(($total + $size)) - - # We always delete all files larger than MAX_KEEP_FILE_SIZE. - # We keep all files smaller than MAX_KEEP_FILE_SIZE when cache size is - # below MAX_CACHE_DIR_SIZE, then we delete also smaller files. - if (("$size" <= "$MAX_KEEP_FILE_SIZE" && "$new_total" < "$MAX_CACHE_DIR_SIZE")) - then - total=$new_total - continue - fi - - filename=$(echo $line | awk '{print $2}') - rm $filename -done diff --git a/scripts/nginx-prune.sh b/scripts/nginx-prune.sh deleted file mode 100755 index ea5a1384..00000000 --- a/scripts/nginx-prune.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# We execute the nginx cache pruning subscript from docker container so that we -# can run the pruning script in user crontab without sudo. -docker run --rm -v /home/user:/home/user bash /home/user/skynet-webportal/scripts/lib/nginx-prune-cache-subscript.sh - -# Some cache files are deleted, but are kept open, we hot reload nginx to get -# them closed and removed from filesystem. -docker exec nginx nginx -s reload diff --git a/setup-scripts/support/crontab b/setup-scripts/support/crontab index 2181d09c..7fffdfb9 100644 --- a/setup-scripts/support/crontab +++ b/setup-scripts/support/crontab @@ -5,4 +5,3 @@ 44 5 * * * /home/user/skynet-webportal/scripts/backup-aws-s3.sh 1>>/home/user/skynet-webportal/logs/backup-aws-s3.log 2>>/home/user/skynet-webportal/logs/backup-aws-s3.log 6 13 * * * /home/user/skynet-webportal/scripts/db_backup.sh 1>>/home/user/skynet-webportal/logs/db_backup.log 2>>/home/user/skynet-webportal/logs/db_backup.log 0 5 * * * /home/user/skynet-webportal/scripts/es_cleaner.py 1 http://localhost:9200 -15 * * * * /home/user/skynet-webportal/scripts/nginx-prune.sh