| Summary: | lighttpd: better systemd service unit | ||
|---|---|---|---|
| Product: | Mageia | Reporter: | Luca Olivetti <luca> |
| Component: | RPM Packages | Assignee: | Mageia Bug Squad <bugsquad> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | Normal | CC: | luigiwalser, mageia |
| Version: | 4 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| URL: | http://lists.freedesktop.org/archives/systemd-devel/2011-January/001067.html | ||
| Whiteboard: | |||
| Source RPM: | lighttpd-1.4.33-4.1.mga4.src.rpm | CVE: | |
| Status comment: | |||
| Bug Depends on: | 16555 | ||
| Bug Blocks: | |||
| Attachments: | lighttpd service unit file | ||
|
Description
Luca Olivetti
2015-05-19 09:43:08 CEST
Created attachment 6575 [details]
lighttpd service unit file
You set version as Mageia 4. Isn't this valid also in Cauldron? Yes, sorry, I put that because that's what I'm using, but cauldron has the same systemd unit.
Samuel Verschelde
2015-05-19 10:13:18 CEST
Version:
4 =>
Cauldron OK, committed in SVN with minor changes. No freeze push requested yet.
Since we removed PIDFile from the service, does it still use the /run/lighttpd directory when it's running (for a PID file or anything else)? If not, we can drop the tmpfiles config too.
Index: SOURCES/lighttpd.service
===================================================================
--- SOURCES/lighttpd.service (revision 822335)
+++ SOURCES/lighttpd.service (working copy)
@@ -3,10 +3,9 @@
After=syslog.target network.target
[Service]
-Type=forking
-PIDFile=/run/lighttpd/lighttpd.pid
-EnvironmentFile=-/etc/sysconfig/lighttpd
-ExecStart=/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
+ExecStartPre=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf
+ExecStart=/usr/sbin/lighttpd-angel -D -f /etc/lighttpd/lighttpd.conf
+ExecReload=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf && /bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
Index: SPECS/lighttpd.spec
===================================================================
--- SPECS/lighttpd.spec (revision 822339)
+++ SPECS/lighttpd.spec (working copy)
@@ -4,7 +4,7 @@
Name: lighttpd
Version: 1.4.35
-Release: %mkrel 4
+Release: %mkrel 5
Summary: A fast webserver with minimal memory-footprint
License: BSD
Group: System/Servers
@@ -186,10 +186,6 @@
%install
%makeinstall_std
-install -d -m 755 %{buildroot}%{_sysconfdir}/sysconfig
-install -m 644 doc/initscripts/sysconfig.lighttpd \
- %{buildroot}%{_sysconfdir}/sysconfig/lighttpd
-
install -d -m 755 %{buildroot}%{_unitdir}
install -m 644 %{SOURCE2} %{buildroot}%{_unitdir}
@@ -281,7 +277,6 @@
%doc doc/config/lighttpd.conf README INSTALL NEWS COPYING AUTHORS
%{_unitdir}/lighttpd.service
%{_prefix}/lib/tmpfiles.d/lighttpd.conf
-%config(noreplace) %{_sysconfdir}/sysconfig/lighttpd
%dir %{_sysconfdir}/lighttpd/
%dir %{_sysconfdir}/lighttpd/conf.d/
%config(noreplace) %{_sysconfdir}/lighttpd/*.confCC:
(none) =>
luigiwalser Yes, it still creates a /run/lighttpd/lighttpd.pid (unless you remove server.pid-file from lighttpd.conf), but since it isn't forking anymore (-D) systemd can determine the pid by itself.
BTW, I checked with your modified ExecReload and it doesn't work:
# systemctl reload lighttpd
Job for lighttpd.service failed. See 'systemctl status lighttpd.service' and 'journalctl -xn' for details.
# systemctl status lighttpd
lighttpd.service - Lightning Fast Webserver With Light System Requirements
Loaded: loaded (/etc/systemd/system/lighttpd.service; enabled)
Active: active (running) (Result: exit-code) since dt 2015-05-19 18:41:10 CEST; 2min 34s ago
Process: 1959 ExecReload=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf && /bin/kill -HUP $MAINPID (code=exited, status=255)
Main PID: 1879 (lighttpd-angel)
CGroup: /system.slice/lighttpd.service
ââ1879 /usr/sbin/lighttpd-angel -D -f /etc/lighttpd/lighttpd.conf
ââ1937 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
It only works correctly if the two commands are separated by ';' and not by '&&' (and, yes, I tested the case with a configuration error, in that case systemd won't execute the kill -HUP).
Ahh, so systemd doesn't support && I guess. That's unintuitive. So maybe the angel isn't needed at all? Maybe this would have worked with a regular lighttpd for the start. ExecReload=/bin/kill -INT $MAINPID ; /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf Oops, you still need to not daemonize it. ExecStartPre=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf ExecReload=/bin/kill -INT $MAINPID ; /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf man systemd.service says that multiple commands must be either separated by ';' or put in multiple directives, that it doesn't interpret shell metacharacters and "If more than one command is specified, the commands are invoked sequentially in the order they appear in the unit file. If one of the commands fails (and is not prefixed with "-"), other lines are not executed, and the unit is considered failed." The angel is needed because it will keep trying to spawn a new lighttpd until it succeeds (it will fail randomly if the previous instance is still using the socket). Yes thanks, poor design on their part. Learn something new every day :o) (In reply to Luca Olivetti from comment #9) > The angel is needed because it will keep trying to spawn a new lighttpd > until it succeeds (it will fail randomly if the previous instance is still > using the socket). I guess that makes sense. It does make me wonder how init scripts I've found that do the kill -INT followed by $0 start don't have that problem. OK, I've fixed the && to be a ;. Asking for a freeze push. Well, let's say that lighttpd development is strange: the current version is 1.4.x, there was a 1.5.x in the works but it never materialized (or at least I couldn't find it), now the next version will be 2.x but that's not really progressing. The documentation reflects this "strangeness", and I just discovered it right after migrating our internal webserver to lighttpd in search of something simpler and lighter weight than apache.... lighttpd-1.4.35-5.mga5 uploaded for Cauldron. Version:
Cauldron =>
4 so what about this bureport then ? we can close it ? CC:
(none) =>
mageia We can backport this change for Mageia 4 and also fix Bug 15948.
David Walser
2015-09-02 17:20:38 CEST
Depends on:
(none) =>
16555 Fixed in: http://advisories.mageia.org/MGASA-2015-0338.html Status:
NEW =>
RESOLVED |