[systemd-devel] Assertion failed in systemd v16

Alexander E. Patrakov patrakov at gmail.com
Mon Jan 10 02:11:26 PST 2011


Hi.

I tried to write a systemd service file for lighttpd (to be used in 
Gentoo). As described here, lighttpd implements a peculiar scheme for 
graceful restarts:

http://blog.lighttpd.net/articles/2005/09/02/graceful-restart

As happens with all too-clever solutions, it doesn't work well.

For those who haven't read the blog and have no experience with 
lighttpd, here is a summary of how it is supposed to be controlled:

1) To test the configuration file for syntax errors, run: 
/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf
2) To run lighttpd in the background as a daemon, /usr/sbin/lighttpd -f 
/etc/lighttpd/lighttpd.conf
3) If you don't want lighttpd to become a daemon, add the -D option. I 
don't use this option.
4) If you want to stop lighttpd and close all connections (equivalent to 
apache2 -k stop), send it the TERM signal
5) If you want lighttpd to stop accepting new connections, but finish 
the existing transfers gracefully (equivalent to apache2 -k 
graceful-stop), send it the INT signal
6) There is no easy procedure for reloading the config while gracefully 
finishing the existing transfers (equivalent to apache2 -k graceful). 
One is supposed to combine the steps (1), (5) and (2) in the initscript.
7) SIGHUP is for reopening the log after rotation, so not used here.

Here is my naive attempt to implement this as a service file:

[Unit]
Description=Lighttpd Web Server
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/lighttpd
PIDFile=/var/run/lighttpd.pid
ExecStartPre=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf
ExecStart=/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
ExecStop=/bin/kill -INT $MAINPID
ExecReload=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf
ExecReload=/bin/kill -INT $MAINPID
ExecReload=/bin/sleep 1
ExecReload=/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target
WantedBy=http-daemon.target

Here is what happened when I tried to reload lighttpd while looking with 
strace whan systemd is doing:

[ 3639.047649] systemd[1]: Assertion 's->control_command_id == 
SERVICE_EXEC_START' failed at src/service.c:2184, function 
service_run_next_main(). Aborting.
[ 3639.052182] systemd[1]: Caught <ABRT>, dumped core as pid 6045.
[ 3639.052376] systemd[1]: Freezing execution.

I could not reproduce the bug without stracing systemd:

strace -ff -e process -p 1

Also, $MAINPID handling seems to be unreliable - e.g., systemctl stop 
lighttpd.service works correctly only while systemd is being straced. 
Replacing /bin/kill -INT $MAINPID with killall -INT $MAINPID removed 
both the unreliability of $MAINPID and the assertion failure. So I guess 
that both bugs are somehow related to my usage of $MAINPID.

-- 
Alexander E. Patrakov


More information about the systemd-devel mailing list