Using /etc/init.d/lighttpd stop|restart does not kill the running lighttpd process. Similar to bug 220161. I noticed that the init script has --pidfile /var/run/lighttpd.pid and this file is never created. Also, if server.pid-file is set in lighttpd.conf, the init script does not honor the setting. This can be temporarily worked around by adding server.pid-file = "/var/run/lighttpd.pid" to lighttpd.conf so that lighttpd creates a pidfile that lines up with the init script's expectations. Reproducible: Always Steps to Reproduce: 1. emerge lighttpd 2. /etc/init.d/lighttpd start 3. /etc/init.d/lighttpd restart Actual Results: * Stopping lighttpd ... [ ok ] * Starting lighttpd ... [ !! ] * ERROR: lighttpd failed to start Expected Results: Started
Interesting bug. It would be better to modify the init script. So, in /etc/conf.d/lighttpd, you would have something like: LIGHTTPD_PID=$(/usr/bin/awk '/^server.pid-file/{s=$3}END{print s}' /etc/lighttpd/lighttpd.conf) and in /etc/init.d/lighttpd you would respect that value. Assigning to maintainers. Thanks for the report.
Thanks, Altering /etc/conf.d/lighttpd did help with honoring lighttpd.conf, however this still doesn't terminate the process (see output) # /etc/init.d/lighttpd stop --debug * Stopping lighttpd ... + start-stop-daemon --stop --quiet --pidfile '"/var/run/lighttpd/lighttpd.pid"' + eend 0 [ ok ] ++ command -v stop_post + '[' '' = stop_post ']' + shift + continue 2 + '[' -n '' ']' # ps aux |grep lighttpd root 2641 0.0 0.1 39628 1000 ? S 19:04 0:00 /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf # cat /var/run/lighttpd/lighttpd.pid 2641 Is this because of the single-quote double-quote surrounding the pidfile?
I cannot reproduce this behavior. In my system, lighttpd starts/stops fine out of the box btrfs-box1 dev # ls /var/run/|grep lighttpd.pid btrfs-box1 dev # /etc/init.d/lighttpd start * Starting lighttpd ... [ ok ] btrfs-box1 dev # ls /var/run/|grep lighttpd.pid lighttpd.pid btrfs-box1 dev # /etc/init.d/lighttpd stop * Stopping lighttpd ... [ ok ] btrfs-box1 dev # ls /var/run/|grep lighttpd.pid btrfs-box1 dev # However, I agree that the init/conf.d script has to be modified to respect custom values in /etc/lighttpd/lighttpd.conf
If it makes a difference, here are my USE flags: [ebuild R ] www-servers/lighttpd-1.4.28-r1 USE="bzip2 ipv6 pcre php rrdtool ssl -doc -fam -gdbm -ldap -libev -lua -memcache -minimal -mysql -test -webdav -xattr" 0 kB
Created attachment 272963 [details, diff] conf.d/init.d fixes Can you please test the attached patch and let me know if it fixes your problem? Try setting an non-default pid value on /etc/lighttpd/lighttpd.conf as well
Perfect. # grep "server.pid-file" /etc/lighttpd/lighttpd.conf server.pid-file = "/var/run/foobar/lighttpd.pid" # cat /var/run/foobar/lighttpd.pid cat: /var/run/foobar/lighttpd.pid: No such file or directory # /etc/init.d/lighttpd start * Starting lighttpd ... [ ok ] # cat /var/run/foobar/lighttpd.pid 19760 # ps aux |grep lighttpd root 19760 0.0 0.2 35636 1092 ? S 11:03 0:00 /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf # /etc/init.d/lighttpd stop * Stopping lighttpd ... [ ok ] # cat /var/run/foobar/lighttpd.pid cat: /var/run/foobar/lighttpd.pid: No such file or directory # ps aux |grep lighttpd # Thanks :)
Fixed in 1.4.28-r2. Thanks for reporting
This is NOT a working solution. Let's imagine I have this in my configuration file, which is perfectly fine as far as the lighttpd syntax goes: var.state_dir = "/var/lib/lighttpd" server.pid-file = state_dir + "/lighttpd.pid" Now the awk one liner returns this: # /usr/bin/awk '/^server.pid-file/{s=$3};{sub("\"","",s)};END{print s}' /etc/lighttpd/lighttpd.conf state_dir and lighttpd is refusing to start because the string "start_dir" is passed to start-stop-daemon instead of the pid file path. # /etc/init.d/lighttpd start * Starting lighttpd ... * start-stop-daemon: failed to start `/usr/sbin/lighttpd' [ !! ] * ERROR: lighttpd failed to start We shouldn't rely on such hacks to work out variables in conf.d files. Please revert this patch or I will revert it myself.
I was on the channel when this was being discussed, and I agree. If you keep the awk code at all, I think it should go in the service script and not in the conf.d file. Also, I recommend leveraging the default start and stop functions if possible (see the openrc-run man page).
(In reply to William Hubbs from comment #9) > If you keep the awk code at all, I think it should go in the service > script and not in the conf.d file. No. Even with awk, it is going to be hard to work out the actual variable name because the lighttpd grammar allow you to reuse previously defined tokens to create new tokens: foo = "my_foo" bar = foo + " is bar" How do you parse that with a one-liner? You can't. This hack should go, full stop.
(In reply to Patrice Clement from comment #8) > This is NOT a working solution. It's not an I will look at it. > We shouldn't rely on such hacks to work out variables in conf.d files. Ok but you have to calm down. > > Please revert this patch or I will revert it myself. That's not a proper way to seek help is it?
There is also another bug. if you don't set 'server.pid-file' the server does not create a pid file and the init script goes crazy. Can you test the following solution on your environment please? diff --git a/www-servers/lighttpd/files/lighttpd.confd b/www-servers/lighttpd/files/lighttpd.confd index f3afb07..c7733de 100644 --- a/www-servers/lighttpd/files/lighttpd.confd +++ b/www-servers/lighttpd/files/lighttpd.confd @@ -6,7 +6,3 @@ # Location of the lighttpd configuration file LIGHTTPD_CONF="/etc/lighttpd/lighttpd.conf" - -# Location of the lighttpd pid file -LIGHTTPD_PID="$(/usr/bin/awk '/^server.pid-file/{s=$3};{sub("\"","",s)};END{print s}' ${LIGHTTPD_CONF})" - diff --git a/www-servers/lighttpd/files/lighttpd.initd b/www-servers/lighttpd/files/lighttpd.initd index 23c0983..8abe3ba 100644 --- a/www-servers/lighttpd/files/lighttpd.initd +++ b/www-servers/lighttpd/files/lighttpd.initd @@ -5,6 +5,8 @@ extra_started_commands="reload graceful" +LIGHTTPD_PID="$($(which lighttpd) -pf ${LIGHTTPD_CONF} | grep pid | cut -d '=' -f 2 | tr -d \\\" | tr -d [:space:])" + depend() { need net use mysql logger spawn-fcgi ldap slapd netmount dns @@ -19,9 +21,10 @@ checkconfig() { fi if [ -z "${LIGHTTPD_PID}" ] ; then - ewarn "server.pid-file variable in ${LIGHTTPD_CONF}" - ewarn "is not set. Falling back to lighttpd.pid" - LIGHTTPD_PID="/run/lighttpd.pid" + eerror "server.pid-file variable in ${LIGHTTPD_CONF}" + eerror "is not set. Please set this variable properly" + eerror "and try again." + return 1 fi /usr/sbin/lighttpd -t -f ${LIGHTTPD_CONF} >/dev/null }
Fixed
(sorry for not commenting this bug before, I was a bit busy up until now) -# Location of the lighttpd pid file -LIGHTTPD_PID="$(/usr/bin/awk '/^server.pid-file/{s=$3};{sub("\"","",s)};END{print s}' ${LIGHTTPD_CONF})" +LIGHTTPD_PID="$($(which lighttpd) -pf ${LIGHTTPD_CONF} | grep pid | cut -d '=' -f 2 | tr -d \\\" | tr -d [:space:])" Hm. Right. So we went to an one-liner awk hack to more hacks piped together. (In reply to Markos Chandras from comment #13) > Fixed Really? To read the configuration file with lighttpd is a good idea so that variables get expended. I like that. However, to spawn 6 shells to do some parsing is not so good. Here's how I would have solved it: --- LIGHTTPD_BIN=$(type -P lighttpd) while read -r line; do if [[ "$line" =~ ^server\.pid-file ]]; then # Break up $line content in positional args i.e. $1, $2, etc. set -- junk "$line" # Shift $junk. shift # Stuff the $* array into another array. pid_file=($*) break fi done < <("$LIGHTTPD_BIN" -pf /etc/lighttpd/lighttpd.conf) LIGHTTPD_PID="${pid_file[2]}" --- That's it. No need for awk, grep, cut, tr, etc. Bash builtins are a lot more efficient.
(In reply to Patrice Clement from comment #14) > (sorry for not commenting this bug before, I was a bit busy up until now) > > -# Location of the lighttpd pid file > -LIGHTTPD_PID="$(/usr/bin/awk > '/^server.pid-file/{s=$3};{sub("\"","",s)};END{print s}' ${LIGHTTPD_CONF})" > > +LIGHTTPD_PID="$($(which lighttpd) -pf ${LIGHTTPD_CONF} | grep pid | cut -d > '=' -f 2 | tr -d \\\" | tr -d [:space:])" > > Hm. Right. So we went to an one-liner awk hack to more hacks piped together. > > (In reply to Markos Chandras from comment #13) > > Fixed > > Really? > Yes, really because I don't like your tone.
(In reply to Markos Chandras from comment #15) > (In reply to Patrice Clement from comment #14) > > Really? > > > > Yes, really because I don't like your tone. Sorry if I sounded rude, it wasn't my intention. I'm always connected on IRC and you can ping me to discuss, or better yet, you can send me an email. I apologised for not responding right away. If you don't want to fix this bug properly then.. whatever. Just leave it.
(In reply to Patrice Clement from comment #16) > (In reply to Markos Chandras from comment #15) > > (In reply to Patrice Clement from comment #14) > > > Really? > > > > > > > Yes, really because I don't like your tone. > > Sorry if I sounded rude, it wasn't my intention. I'm always connected on IRC > and you can ping me to discuss, or better yet, you can send me an email. I > apologised for not responding right away. > > If you don't want to fix this bug properly then.. whatever. Just leave it. you seem to forget that bash built-ins are not allowed in init scripts. they are supposed to be shell independent.