Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1000310: lighttpd: logrotate fails if service is not running

45 views
Skip to first unread message

Christian Göttsche

unread,
Nov 21, 2021, 5:10:03 AM11/21/21
to
Package: lighttpd
Version: 1.4.61-1
File: /etc/logrotate.d/lighttpd

When the lighttpd service is not active, logrotate fails:

systemd[1]: Starting Rotate log files...
logrotate[402728]: lighttpd.service is not active, cannot reload.
logrotate[402723]: error: error running shared postrotate script for
'/var/log/lighttpd/*.log '
systemd[1]: logrotate.service: Main process exited, code=exited,
status=1/FAILURE
systemd[1]: logrotate.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Rotate log files.

Please consider reloading only when active, e.g.:

systemctl -q is-active lighttpd.service && systemctl reload lighttpd.service

Glenn Strauss

unread,
Nov 22, 2021, 2:30:03 AM11/22/21
to
> This also fails, the following works:
>
> systemctl reload lighttpd.service > /dev/null 2>&1;

That will start lighttpd if it is not running, which might not be
desirable. I think that a different solution is warranted.

/etc/logrotate.d/lighttpd is doing the correct thing, calling
/etc/init.d/lighttpd reopen-logs

However, perhaps /etc/init.d/lighttpd should avoid sending a signal to
lighttpd to reopen logs if lighttpd is not running.
/etc/init.d/lighttpd might check using pidofproc, even though
running start-stop-daemon --oknodo --quiet should have exited 0
if nothing was running.

Does the following work for you?

@@ -92,6 +92,7 @@ case "$1" in
fi
;;
reopen-logs)
+ pidofproc -p "$PIDFILE" "$DAEMON" >/dev/null 2>&1 || exit 0
log_daemon_msg "Reopening $DESC logs" $NAME
if start-stop-daemon --stop --signal HUP --oknodo --quiet \
--pidfile $PIDFILE --exec $DAEMON
0 new messages