lancachenet / monolithic

A monolithic lancache service capable of caching all CDNs in a single instance
https://hub.docker.com/r/lancachenet/monolithic
Other
726 stars 73 forks source link

Rotate logs? #136

Closed adilinden closed 2 years ago

adilinden commented 2 years ago

Describe the issue you are having

Log files are simply growing (forever?) I see there is the LOGFILE_RETENTION variable but it seems to clean up old files, it doesn't actually trigger the creation of new log files. Currently LOGFILE_RETENTION is not specified in .env, so assuming the 3560 default value is in effect.

How are you running the container(s)

version: '2'
services:
  dns:
    image: lancachenet/lancache-dns:latest
    env_file: .env
    restart: unless-stopped
    ports:
      - ${DNS_BIND_IP}:53:53/udp
      - ${DNS_BIND_IP}:53:53/tcp
  monolithic:
    image: lancachenet/monolithic:latest
    env_file: .env
    restart: unless-stopped
    ports:
      - 80:80/tcp
      - 443:443/tcp
    volumes:
      - ${CACHE_ROOT}/cache:/data/cache
      - ${CACHE_ROOT}/logs:/data/logs

DNS Configuration

DNS is part of monolithic

Output of container(s)


cacheadmin@cache:~/lancache$ ls -alh /mnt/lancache/cache/logs/
total 9.3G
drwxr-xr-x 2 root root 4.0K May 25 14:19 .
drwxr-xr-x 4 root root 4.0K May 25 14:19 ..
-rw-r--r-- 1 root root 8.8G Sep  8 15:28 access.log
-rw-r--r-- 1 root root 370M Sep  8 15:28 error.log
-rw-r--r-- 1 root root  81M Sep  8 15:28 stream-access.log
-rw-r--r-- 1 root root  17M Sep  8 15:27 stream-error.log```
MathewBurnett commented 2 years ago

i would advise using log rotate (this might help https://docs.rackspace.com/support/how-to/understanding-logrotate-utility/) below is an example of what you use for a postrotate script to help the container let go of the log file.


daily
rotate 7
size 10M
compress
delaycompress
postrotate
    if test $(docker ps -q --filter "name=lancache_monolithic_1"); then docker exec lancache_monolithic_1 sh -c 'kill -USR1 $(cat /var/run/nginx.pid)'; fi
endscript
}```
adilinden commented 2 years ago

It works! Thanks!