]> granicus.if.org Git - pdns/commitdiff
sd_notify support in the auth server
authorPieter Lexis <pieter.lexis@powerdns.com>
Mon, 25 Apr 2016 12:56:23 +0000 (14:56 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 4 May 2016 14:03:09 +0000 (16:03 +0200)
configure.ac
contrib/systemd-pdns.service
pdns/Makefile.am
pdns/common_startup.cc

index 388e1c1dacc319b8856960ee528f036e4955253c..3920a42639f9851066633ce4f77332c838b531f1 100644 (file)
@@ -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"
index 422ab898d3e26c0efe74693bd79d6c656a1ebe12..f16f07c77a673292d2c9e55137b768674b95532a 100644 (file)
@@ -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
index 07f1e1fca3026558e5726f294f599180cb642470..92a7290b881b0c5745882757ac6367e76a5cbbd5 100644 (file)
@@ -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
index 1f06d0bf6d06d488339e0252fbdde07d650b46e6..3da8565de0404ebca50b7bcb7413aed5fce2bb1d 100644 (file)
@@ -29,6 +29,9 @@
 #include <sys/resource.h>
 #include "dynhandler.hh"
 
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-daemon.h>
+#endif
 
 bool g_anyToTcp;
 typedef Distributor<DNSPacket,DNSPacket,PacketHandler> 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 {