diff --git a/CHANGELOG.md b/CHANGELOG.md index 052bb96..839a5d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,13 @@ ## Changes 10/7/2025 (no new version) -feat(start.sh): stream Apache logs to console + startup polish +feat(startup): stream error.log to console by default; add LOG_STREAM selector -- Tail /var/www/metadata/log/{access,error}.log to container stdout (STREAM_LOGS=true by default) -- Ensure log/session dirs exist with sane perms; no port/vhost changes -- Keep Apache in foreground; clearer startup message +- Touch error/access logs on start so tail can attach immediately +- Add LOG_STREAM=error|access|both|none (default: error) +- Tail with `-n0 -F` to follow new entries only and survive rotations +- Keep access.log on disk but don’t spam console unless requested +- (Unraid) Optional env var template entry for LOG_STREAM ## Changes 10/6/2025 v1.3.15 diff --git a/start.sh b/start.sh index c268a42..7a35fde 100644 --- a/start.sh +++ b/start.sh @@ -56,11 +56,9 @@ fi mkdir -p /var/www/metadata/log chown www-data:www-data /var/www/metadata/log chmod 775 /var/www/metadata/log - -: > /var/www/metadata/log/access.log : > /var/www/metadata/log/error.log -chown www-data:www-data /var/www/metadata/log/access.log /var/www/metadata/log/error.log -chmod 664 /var/www/metadata/log/access.log /var/www/metadata/log/error.log +: > /var/www/metadata/log/access.log +chown www-data:www-data /var/www/metadata/log/*.log mkdir -p /var/www/sessions chown www-data:www-data /var/www/sessions @@ -159,12 +157,16 @@ if [ "${SCAN_ON_START:-}" = "true" ]; then fi # 9.6) Stream Apache logs to the container console (optional toggle) -if [ "${STREAM_LOGS:-true}" = "true" ]; then - echo "[startup] Streaming Apache logs to container console..." - # access.log -> STDOUT, error.log -> STDERR - tail -n0 -F /var/www/metadata/log/access.log >> /proc/1/fd/1 & - tail -n0 -F /var/www/metadata/log/error.log >> /proc/1/fd/2 & -fi +LOG_STREAM="${LOG_STREAM:-error}" +case "${LOG_STREAM,,}" in + none) STREAM_ERR=false; STREAM_ACC=false ;; + access) STREAM_ERR=false; STREAM_ACC=true ;; + both) STREAM_ERR=true; STREAM_ACC=true ;; + error|*)STREAM_ERR=true; STREAM_ACC=false ;; +esac -echo "✅ Apache starting (foreground). Check container logs for access/error output…" -exec apachectl -D FOREGROUND +echo "🔥 Starting Apache..." +# Stream only the chosen logs; -n0 = don't dump history, -F = follow across rotations/creation +[ "${STREAM_ERR}" = "true" ] && tail -n0 -F /var/www/metadata/log/error.log 2>/dev/null & +[ "${STREAM_ACC}" = "true" ] && tail -n0 -F /var/www/metadata/log/access.log 2>/dev/null & +exec apachectl -D FOREGROUND \ No newline at end of file