From 2db09515d7c2fe05eddd4e6cf4e1a3fc71e58a33 Mon Sep 17 00:00:00 2001 From: edgd1er Date: Fri, 28 Jan 2022 08:12:40 +0100 Subject: [PATCH] add suggested changes to send logs to stdout Signed-off-by: edgd1er --- .../etc/services.d/lighttpd-access-log/finish | 1 - .../etc/services.d/lighttpd-access-log/run | 4 ++-- .../etc/services.d/lighttpd-error-log/finish | 1 - .../etc/services.d/lighttpd-error-log/run | 2 +- s6/debian-root/etc/services.d/lighttpd/finish | 2 +- s6/debian-root/etc/services.d/lighttpd/run | 14 ++++++++++---- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/s6/debian-root/etc/services.d/lighttpd-access-log/finish b/s6/debian-root/etc/services.d/lighttpd-access-log/finish index 42d98d3..5802d5b 100644 --- a/s6/debian-root/etc/services.d/lighttpd-access-log/finish +++ b/s6/debian-root/etc/services.d/lighttpd-access-log/finish @@ -3,7 +3,6 @@ s6-echo "Stopping lighttpd-access-log" pid=$(ps -C cat -o pid=,args= |grep -oP "([0-9]+).+access\.log" |cut -f1 -d" ") if [[ -n ${pid} ]]; then - echo "Killing ${pid}" kill -9 ${pid} fi s6-echo "Stopped lighttpd-access-log" diff --git a/s6/debian-root/etc/services.d/lighttpd-access-log/run b/s6/debian-root/etc/services.d/lighttpd-access-log/run index 79a603e..1473767 100644 --- a/s6/debian-root/etc/services.d/lighttpd-access-log/run +++ b/s6/debian-root/etc/services.d/lighttpd-access-log/run @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bash -s6-echo "Redirecting FIFO access log to stdout" +s6-echo "Starting lighttpd-access-log" -s6-setuidgid www-data cat /var/log/lighttpd/access.log 2>&1 \ No newline at end of file +s6-setuidgid www-data cat /var/log/lighttpd/access.log 2>&1 diff --git a/s6/debian-root/etc/services.d/lighttpd-error-log/finish b/s6/debian-root/etc/services.d/lighttpd-error-log/finish index 4dbdb29..8fbad41 100644 --- a/s6/debian-root/etc/services.d/lighttpd-error-log/finish +++ b/s6/debian-root/etc/services.d/lighttpd-error-log/finish @@ -3,7 +3,6 @@ s6-echo "Stopping lighttpd-error-log" pid=$(ps -C cat -o pid=,args= |grep -oP "([0-9]+).+error\.log" |cut -f1 -d" ") if [[ -n ${pid} ]]; then - echo "Killing ${pid}" kill -9 ${pid} fi s6-echo "Stopped lighttpd-error-log" diff --git a/s6/debian-root/etc/services.d/lighttpd-error-log/run b/s6/debian-root/etc/services.d/lighttpd-error-log/run index a0f59d7..c0636fc 100644 --- a/s6/debian-root/etc/services.d/lighttpd-error-log/run +++ b/s6/debian-root/etc/services.d/lighttpd-error-log/run @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bash -s6-echo "Redirecting FIFO error log to stdout" +s6-echo "Starting lighttpd-error-log" s6-setuidgid www-data cat /var/log/lighttpd/error.log 2>&1 diff --git a/s6/debian-root/etc/services.d/lighttpd/finish b/s6/debian-root/etc/services.d/lighttpd/finish index ed4eacb..b4dbfa4 100644 --- a/s6/debian-root/etc/services.d/lighttpd/finish +++ b/s6/debian-root/etc/services.d/lighttpd/finish @@ -1,6 +1,6 @@ #!/usr/bin/with-contenv bash s6-echo "Stopping lighttpd" -killall -9 lighttpd service lighttpd-access-log stop service lighttpd-error-log stop +killall -9 lighttpd diff --git a/s6/debian-root/etc/services.d/lighttpd/run b/s6/debian-root/etc/services.d/lighttpd/run index 5bea243..b60786b 100644 --- a/s6/debian-root/etc/services.d/lighttpd/run +++ b/s6/debian-root/etc/services.d/lighttpd/run @@ -4,15 +4,21 @@ s6-echo "Starting lighttpd" if [[ 1 -eq ${WEBLOGS_STDOUT:-0} ]]; then #lighthttpd cannot use /dev/stdout https://redmine.lighttpd.net/issues/2731 - rm -f /var/log/lighttpd/access.log - mkfifo -m 600 /var/log/lighttpd/access.log - rm -f /var/log/lighttpd/error.log - mkfifo -m 600 /var/log/lighttpd/error.log + for fi in /var/log/lighttpd/access.log /var/log/lighttpd/error.log + do + if [[ ! -p ${fi} ]]; then + rm -f ${fi} + mkfifo -m 600 ${fi} + fi + done chown -R www-data:www-data /var/log/lighttpd service lighttpd-access-log start service lighttpd-error-log start sleep 2 else + #remove fifo if exists + [[ -p /var/log/lighttpd/access.log ]] && rm -Rf /var/log/lighttpd/access.log + [[ -p /var/log/lighttpd/error.log ]] && rm -Rf /var/log/lighttpd/error.log # Touch log files to ensure they exist (create if non-existing, preserve if existing) touch /var/log/lighttpd/access.log /var/log/lighttpd/error.log