From 4c71a16d16fc0462649f52ceb241e4c70b0fab8f Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 11 Feb 2025 16:24:49 -0500 Subject: [PATCH 1/4] Set up the `nginx` directory under `/config/log` This does quick and dirty rotation of the nginx directory. This is needed because of the earlier ownership / permissions changes not accounting for the web server user. Also, the logs won't grow forever; which is nice. --- .../root/etc/s6-overlay/s6-rc.d/tubesync-init/run | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/config/root/etc/s6-overlay/s6-rc.d/tubesync-init/run b/config/root/etc/s6-overlay/s6-rc.d/tubesync-init/run index 4ac5ff8e1..acc73228f 100755 --- a/config/root/etc/s6-overlay/s6-rc.d/tubesync-init/run +++ b/config/root/etc/s6-overlay/s6-rc.d/tubesync-init/run @@ -29,6 +29,21 @@ then chmod -R 0755 /downloads fi +# Prepare for nginx logging into /config/log/nginx +mkdir -p /config/log +rm -rf /config/log/nginx.9 +for n in $(seq 8 -1 0) +do + test '!' -d "/config/log/nginx.${n}" || + mv "/config/log/nginx.${n}" "/config/log/nginx.$((1 + n))" +done ; unset -v n ; +rm -rf /config/log/nginx.0 +test '!' -d /config/log/nginx || +mv /config/log/nginx /config/log/nginx.0 +rm -rf /config/log/nginx +cp -a /var/log/nginx /config/log/ +cp -p /config/log/nginx/access.log /config/log/nginx/access.log.gz + # Run migrations exec s6-setuidgid app \ /usr/bin/python3 /app/manage.py migrate From 226c698307541ecb4e77c288696f0d25c033a748 Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 11 Feb 2025 16:35:49 -0500 Subject: [PATCH 2/4] Log to `/config/log/nginx` The error log contains informational and higher levels on the theory that when something goes wrong we will want as much information as we can get about why an error occurred. Access log is compressed, in memory, then written to disk every minute. Most people will take about that long to start reading the file anyway. --- config/root/etc/nginx/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/root/etc/nginx/nginx.conf b/config/root/etc/nginx/nginx.conf index f09c02e17..428543dca 100644 --- a/config/root/etc/nginx/nginx.conf +++ b/config/root/etc/nginx/nginx.conf @@ -37,8 +37,8 @@ http { # Logging log_format host '$remote_addr - $remote_user [$time_local] "[$host] $request" $status $bytes_sent "$http_referer" "$http_user_agent" "$gzip_ratio"'; - access_log /dev/stdout; - error_log stderr; + access_log /config/log/nginx/access.log.gz combined gzip=9 flush=1m; + error_log /config/log/nginx/error.log info; # GZIP gzip on; From 19f958dac1a70da84c74a0c5a47835446a856d9d Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 11 Feb 2025 17:04:51 -0500 Subject: [PATCH 3/4] Adjust the example restart policy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af3cd910d..a31057d16 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ services: tubesync: image: ghcr.io/meeb/tubesync:latest container_name: tubesync - restart: unless-stopped + restart: on-failure:3 ports: - 4848:4848 volumes: From 058d9f589114b8579e33ed48384c85714ea93e3f Mon Sep 17 00:00:00 2001 From: tcely Date: Thu, 13 Mar 2025 10:52:14 -0400 Subject: [PATCH 4/4] Move conflicting lines into position --- config/root/etc/nginx/nginx.conf | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/config/root/etc/nginx/nginx.conf b/config/root/etc/nginx/nginx.conf index dc41fd867..6618aed9c 100644 --- a/config/root/etc/nginx/nginx.conf +++ b/config/root/etc/nginx/nginx.conf @@ -11,10 +11,6 @@ events { http { - # Logging - access_log /config/log/nginx/access.log.gz combined gzip=9 flush=1m; - error_log /config/log/nginx/error.log info; - # Basic settings sendfile on; tcp_nopush on; @@ -41,8 +37,8 @@ http { # Logging log_format host '$remote_addr - $remote_user [$time_local] "[$host] $request" $status $bytes_sent "$http_referer" "$http_user_agent" "$gzip_ratio"'; - access_log /dev/stdout; - error_log stderr; + access_log /config/log/nginx/access.log.gz combined gzip=9 flush=1m; + error_log /config/log/nginx/error.log info; # GZIP gzip on;