diff --git a/docker-compose.yml b/docker-compose.yml index 508875e..3b7c914 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,4 +47,5 @@ services: - 8080:80 volumes: - ./data:/app/public/data - - ./logs:/app/public/logs \ No newline at end of file + - ./logs:/app/public/logs + - ./redis:/var/lib/redis # can be commeted out if REDIS_CACHING is set to false \ No newline at end of file diff --git a/docker/rootfs/start.sh b/docker/rootfs/start.sh index 5ab7cbf..0264ee5 100644 --- a/docker/rootfs/start.sh +++ b/docker/rootfs/start.sh @@ -65,7 +65,16 @@ _buildConfig() { # starting redis if [[ ${REDIS_CACHING:=true} == true ]]; then - echo "[i] Starting Redis" + echo "[i] Redis steps" + # tell redis how often to save + ## save + echo " [+] Configuring Redis save intervals" + echo "save 60 100" >> /etc/redis.conf # every minute if at least 100 keys changed + echo "save 300 10" >> /etc/redis.conf # every 5 minutes if at least 10 keys changed + echo "save 600 1" >> /etc/redis.conf # every 10 minutes if at least 1 key changed + + # Trap SIGTERM and SIGINT signals to save Redis data before shutdown + trap "echo 'Stopping Redis'; redis-cli save; redis-cli shutdown; exit" TERM INT redis-server /etc/redis.conf --daemonize yes fi