[Dovecot] add basic systemd support to dovecot
Hi all,
In the last days, I've been trying to add support for systemd[1] socket activation to dovecot. The basic idea is that systemd takes care of opening the sockets needed by dovecot to communicate with external processes, and when a connection happens on one of these sockets, systemd spawns dovecot, and then dovecot uses these sockets instead of creating its own sockets. The main reason why I hacked on this was that I wanted to get on-demand startup of dovecot on my home box.
WIth the patch attached to this email, I'm now able to do that. The patch includes a dovecot.socket file which should be seen as a sample file, however I'm not sure what is the best way to handle this file (systemd uses it to know which sockets dovecot needs).
What I wanted to ask the list for now is if such a patch is wanted, and to get feedback on how things are done in it, and what should be improved in it. [2] and [3] might be useful reading while looking at the patch.
Thanks in advance for the feedback!
Christophe
[1] http://www.freedesktop.org/wiki/Software/systemd [2] http://0pointer.de/public/systemd-man/daemon.html [3] http://0pointer.de/public/systemd-man/sd-daemon.html
On Wed, 2010-10-20 at 22:54 +0200, Christophe Fergeau wrote:
What I wanted to ask the list for now is if such a patch is wanted, and to get feedback on how things are done in it, and what should be improved in it. [2] and [3] might be useful reading while looking at the patch.
You can simplify the environment preserving with these changes:
http://hg.dovecot.org/dovecot-2.0/rev/e0a97842182f http://hg.dovecot.org/dovecot-2.0/rev/d1fd5b84d410
+if HAVE_SYSTEMD +dovecot_SOURCES += sd-daemon.c +noinst_HEADERS += sd-daemon.h +endif
I don't think this is portable. You could do it instead like:
if HAVE_SYSTEMD SD_SOURCES = sd-daemon.c endif
dovecot_SOURCES =
$(SD_SOURCES)
..
noinst_HEADERS =
sd-daemon.h
..
I don't think there's any reason to put sd-daemon.h behind "if".
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
[], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
Is this a common name for this option? If not, I'd prefer a shorter name.
On Mon, 2010-10-25 at 17:47 +0100, Timo Sirainen wrote:
+if HAVE_SYSTEMD +dovecot_SOURCES += sd-daemon.c +noinst_HEADERS += sd-daemon.h +endif
I don't think this is portable.
Or looks like it's already used in lib-sql/Makefile.am. Maybe it works fine then. Or probably doesn't matter anyway since this is Linux-only code and GNU make is always used there. So just keep this as is. :)
Hi,
Sorry for the delay in replying, I was away for a few weeks :) I have finally reworked the patch according to your feedback.
On Mon, Oct 25, 2010 at 05:47:20PM +0100, Timo Sirainen wrote:
You can simplify the environment preserving with these changes:
http://hg.dovecot.org/dovecot-2.0/rev/e0a97842182f http://hg.dovecot.org/dovecot-2.0/rev/d1fd5b84d410
Ah, that indeed makes things much simpler, thanks!
I don't think this is portable. You could do it instead like:
Ok, I changed it even after reading your other email.
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
[], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
Is this a common name for this option? If not, I'd prefer a shorter name.
I asked upstream about it, and I was told it's the usual way of naming options with the autotools, so they'd prefer if it was kept this way. But I don't mind changing it to something else if you prefer, I have a patch changing it to --with-systemd if needed.
Here is the updated patch, if you want I also have it as a patch series: systemd: Add proper systemd configure.in blob (from daemon(7)) systemd: Preserve LISTEN_FDS and LISTEN_PID during env cleanup when systemd is used systemd: Use sockets provided by systemd if possible systemd: When systemd didn't provide a suitable socket, fallback to the regular socket creation code systemd: Add systemd unit files
Christophe
On Sun, 2010-11-14 at 22:44 +0100, Christophe Fergeau wrote:
Sorry for the delay in replying, I was away for a few weeks :) I have finally reworked the patch according to your feedback.
Committed, with some small changes: http://hg.dovecot.org/dovecot-2.0/rev/84eb4afebc95
I hope it still works :)
2010/11/17 Timo Sirainen tss@iki.fi:
Committed, with some small changes: http://hg.dovecot.org/dovecot-2.0/rev/84eb4afebc95
Great, thanks a lot!
I hope it still works :)
I'll let you know if it breaks ;)
Christophe
participants (2)
-
Christophe Fergeau
-
Timo Sirainen