/etc/init.d/lighttpd tries to parse the server.pid-file from /etc/lighttpd/lighttpd.conf using the line LIGHTTPD_PID="$(grep pid ${LIGHTTPD_CONF} | cut -d '=' -f 2 | tr -d \\\" | tr -d [:space:])" This results in two problems. First, the LIGHTTPD_PID is also configured in /etc/conf.d/lighttpd as LIGHTTPD_PID="/var/run/lighttpd.pid" Then, the parser for the /etc/lighttpd/lighttpd.conf fails if any other line contains "pid", as in this case: $HTTP["useragent"] =~ "spider" { accesslog.filename = "/var/www/foo/logs/robots.log" } spider contains pid, and so LIGHTTPD_PID is set to /var/run/lighttpd.pid~spider{ This filename is then written out to /run/openrc/daemons/lighttpd/001. Since lighttpd itself uses /etc/lighttpd/lighttpd.conf, the actual PID is written to lighttpd.pid; but then /etc/init.d/lighttpd status looks at /var/run/lighttpd.pid~spider{ and hence reports the wrong status "crashed". (1) Is there a reason why the value from /etc/conf.d/lighttpd is overwritten? If not, the parser from /etc/init.d/lighttpd could be dropped. If yes: (2) This would be a saner option: LIGHTTPD_PID="$(sed -n 's/^[^#]*server.pid-file[[:space:]]*=[[:space:]]*\"\([^"]*\)\"/\1/p' ${LIGHTTPD_CONF})"
There is some history to this bug. The origin of stepping on the /etc/conf.d value came from https://bugs.gentoo.org/366811, where there was some disagreement over the solution and it was included with the knowledge that it's fragile. I'm hesitant to adjust the problematic line because I'd prefer not to trigger another parsing strategy debate. To add to your observation, this also fails if the pid is specified in lighttpd.conf but commented out. It looks to me like the underlying problem, lighttpd not writing out a pid file unless explicitly told to do so, is what needs addressed, then we can adjust the tooling around it. Upstream is responsive, and I'm happy to work with them on a solution. I'm thinking of two ways of approaching this: - Could lighttpd just have a default if one isn't set? This would eliminate the need for LIGHTTPD_PID to appear in /etc/conf.d at all. I'm not sure if not writing one out is by design, so I'll ask upstream. (We'd still have to fix the parsing.) - Could upstream add a way of specifying the pid as a switch when launching? That way we could use LIGHTTPD_PID in /etc/conf.d exclusively and ignore lighttpd.conf, though that might cause some confusion for users expecting lighttpd.conf to take precedence. On a side note, but potentially relevant is https://bugs.gentoo.org/598468. At one time we were just asking lighttpd itself for the config and grabbing the pid from that, but that fell apart because of the order of things. It was getting called before the filesystem was switched to read/write. Maybe we could ask upstream for a way to ask lighttpd specifically for its pid?
Dear Gentoo devs, can we mark this one confirmed? Markus and I are both able to reproduce. I opened https://redmine.lighttpd.net/issues/3072 with upstream to see if we can make changes that make this easier to solve without command line parsing.
Shortly after https://bugs.gentoo.org/598468 (Oct/Nov 2016), lighttpd 1.4.44 was released in Dec 2016 and deferred the call to li_rand_init(). That change in lighttpd 1.4.44 should have addressed the issue raised in https://bugs.gentoo.org/598468. Therefore, the change made in https://bugs.gentoo.org/598468 to remove LIGHTTPD_PID="$($(which lighttpd) -pf ${LIGHTTPD_CONF} | grep pid | cut -d '=' -f 2 | tr -d \\\" | tr -d [:space:])" can probably be restored. However, if server.pid-file is not configured (or is commented out), then lighttpd.initd should take an alternate approach. Some alternatives are suggested in https://redmine.lighttpd.net/issues/3072 The current behavior in https://github.com/gentoo/gentoo/blob/master/www-servers/lighttpd/files/lighttpd.initd is also fine: checkconfig() returns an error with trace that server.pid-file should be configured in lighttpd.conf
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=855a7edcadc8ee44e8bddebaf8b6b33b94d7190d commit 855a7edcadc8ee44e8bddebaf8b6b33b94d7190d Author: Glenn Strauss <gstrauss@gluelogic.com> AuthorDate: 2022-01-21 14:10:47 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2022-01-23 17:57:13 +0000 www-servers/lighttpd: adjust lighttpd.initd Closes: https://bugs.gentoo.org/626688 Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com> Closes: https://github.com/gentoo/gentoo/pull/23900 Signed-off-by: Sam James <sam@gentoo.org> .../lighttpd/{lighttpd-1.4.64-r1.ebuild => lighttpd-1.4.64.ebuild} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)