From: Pieter Lexis Date: Mon, 25 Apr 2016 12:56:23 +0000 (+0200) Subject: sd_notify support in the auth server X-Git-Tag: rec-4.0.0-alpha3~5^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6988eae995cf47d024a974ecf5dda77b4284ee6b;p=pdns sd_notify support in the auth server --- diff --git a/configure.ac b/configure.ac index 388e1c1da..3920a4263 100644 --- a/configure.ac +++ b/configure.ac @@ -262,6 +262,9 @@ for a in $dynmodules; do fi done +AX_AVAILABLE_SYSTEMD +AM_CONDITIONAL([HAVE_SYSTEMD], [ test x"$systemd" = "xy" ]) + LDFLAGS="$RELRO_LDFLAGS $LDFLAGS" CFLAGS="$PIE_CFLAGS $CFLAGS" diff --git a/contrib/systemd-pdns.service b/contrib/systemd-pdns.service index 422ab898d..f16f07c77 100644 --- a/contrib/systemd-pdns.service +++ b/contrib/systemd-pdns.service @@ -1,12 +1,13 @@ [Unit] Description=PowerDNS Authoritative Server Documentation=man:pdns_server(1) man:pdns_control(1) +Documentation=https://doc.powerdns.com Wants=network-online.target After=network-online.target mysqld.service postgresql.service slapd.service [Service] -Type=forking -ExecStart=/usr/sbin/pdns_server --daemon +Type=notify +ExecStart=/usr/sbin/pdns_server --guardian=no --daemon=no --disable-syslog --write-pid=no Restart=on-failure StartLimitInterval=0 PrivateTmp=true diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 07f1e1fca..92a7290b8 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -4,7 +4,8 @@ AM_CPPFLAGS += \ -I$(top_srcdir)/ext/json11 \ $(YAHTTP_CFLAGS) \ $(LIBEDIT_CFLAGS) \ - $(OPENSSL_INCLUDES) + $(OPENSSL_INCLUDES) \ + $(SYSTEMD_CFLAGS) AM_CXXFLAGS = \ -DSYSCONFDIR=\"$(sysconfdir)\" \ @@ -210,7 +211,8 @@ pdns_server_LDADD = \ $(LIBDL) \ $(YAHTTP_LIBS) \ $(JSON11_LIBS) \ - $(OPENSSL_LIBS) + $(OPENSSL_LIBS) \ + $(SYSTEMD_LIBS) if BOTAN110 pdns_server_SOURCES += botan110signers.cc diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 1f06d0bf6..3da8565de 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -29,6 +29,9 @@ #include #include "dynhandler.hh" +#ifdef HAVE_SYSTEMD +#include +#endif bool g_anyToTcp; typedef Distributor DNSDistributor; @@ -533,6 +536,15 @@ void mainthread() pthread_create(&qtid,0,carbonDumpThread, 0); // runs even w/o carbon, might change @ runtime +#ifdef HAVE_SYSTEMD + /* If we are here, notify systemd that we are ay-ok! This might have some + * timing issues with the backend-threads. e.g. if the initial MySQL connection + * is slow and times out (leading to process termination through the backend) + * We probably have told systemd already that we have started correctly. + */ + sd_notify(0, "READY=1"); +#endif + for(;;) { sleep(1800); try {