Ported CACHE_INDEX_SIZE PR from generic

Ported PR https://github.com/lancachenet/generic/pull/103/ from @crabbey
Changes CACHE_MEM_SIZE to CACHE_INDEX_SIZE but maintains backwards compatiblity through deprecation.sh
This commit is contained in:
VibroAxe 2021-10-09 10:24:38 +00:00 committed by GitHub
parent 425a75c7da
commit 2fa012f667
4 changed files with 14 additions and 3 deletions

View file

@ -6,7 +6,7 @@ LABEL maintainer="LanCache.Net Team <team@lancache.net>"
ENV GENERICCACHE_VERSION=2 \
CACHE_MODE=monolithic \
WEBUSER=www-data \
CACHE_MEM_SIZE=500m \
CACHE_INDEX_SIZE=500m \
CACHE_DISK_SIZE=1000000m \
CACHE_MAX_AGE=3560d \
CACHE_SLICE_SIZE=1m \

View file

@ -1 +1 @@
proxy_cache_path /data/cache/cache levels=2:2 keys_zone=generic:CACHE_MEM_SIZE inactive=200d max_size=CACHE_DISK_SIZE loader_files=1000 loader_sleep=50ms loader_threshold=300ms use_temp_path=off;
proxy_cache_path /data/cache/cache levels=2:2 keys_zone=generic:CACHE_INDEX_SIZE inactive=200d max_size=CACHE_DISK_SIZE loader_files=1000 loader_sleep=50ms loader_threshold=300ms use_temp_path=off;

View file

@ -7,3 +7,9 @@ if [[ ! -z "${CACHE_DOMAIN_REPO}" ]]; then
fi
if [[ ! -z "${CACHE_INDEX_SIZE}" ]]; then
echo " *** CACHE_MEM_SIZE has been deprecated in place of CACHE_INDEX_SIZE"
echo " *** Using CACHE_MEM_SIZE as the value"
echo " *** Please update your configuration at your earliest convenience"
CACHE_INDEX_SIZE=$CACHE_MEM_SIZE
fi

View file

@ -1,12 +1,17 @@
#!/bin/sh
set -e
# Handle CACHE_MEM_SIZE deprecation
if [[ ! -z "${CACHE_MEM_SIZE}" ]]; then
CACHE_INDEX_SIZE=${CACHE_MEM_SIZE}
fi
# Preprocess UPSTREAM_DNS to allow for multiple resolvers using the same syntax as lancache-dns
UPSTREAM_DNS="$(echo -n "${UPSTREAM_DNS}" | sed 's/[;]/ /g')"
echo "worker_processes ${NGINX_WORKER_PROCESSES};" > /etc/nginx/workers.conf
sed -i "s/^user .*/user ${WEBUSER};/" /etc/nginx/nginx.conf
sed -i "s/CACHE_MEM_SIZE/${CACHE_MEM_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf
sed -i "s/CACHE_INDEX_SIZE/${CACHE_INDEX_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf
sed -i "s/CACHE_DISK_SIZE/${CACHE_DISK_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf
sed -i "s/CACHE_MAX_AGE/${CACHE_MAX_AGE}/" /etc/nginx/sites-available/cache.conf.d/root/20_cache.conf
sed -i "s/slice 1m;/slice ${CACHE_SLICE_SIZE};/" /etc/nginx/sites-available/cache.conf.d/root/20_cache.conf