Commit af20e8b7 authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'systemd' into 'master'

Systemd
parents bf7f5b2c 0b81983c
......@@ -85,6 +85,22 @@ AS_CASE([$enable_fastparser],
AM_CONDITIONAL([G2_PARSER], test "$enable_fastparser" = "yes")
AM_CONDITIONAL([T0_PARSER], test "$enable_fastparser" = "no")
# Systemd integration
AC_ARG_ENABLE([systemd],
AS_HELP_STRING([--enable-systemd=auto|yes|no], [enable systemd notification mechanism [default=auto]]),
[enable_systemd="$enableval"], [enable_systemd=auto])
case "$enable_systemd" in
auto) PKG_CHECK_MODULES([systemd_daemon], [libsystemd-daemon], [enable_systemd=yes], [enable_systemd=no]) ;;
yes) PKG_CHECK_MODULES([systemd_daemon], [libsystemd-daemon]) ;;
no) ;;
*) AC_MSG_ERROR([Invalid value of --enable-systemd.]) ;;
esac
if test "$enable_systemd" = yes; then
AC_DEFINE([ENABLE_SYSTEMD_NOTIFY], [1], [Use systemd notifications.])
fi
# Debug modules
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug=server,zones,xfr,packet,rr,ns,loader,dnssec],
......@@ -371,5 +387,6 @@ echo "
Libs: ${LIBS}
Ragel: ${RAGEL} ${FSM_TYPE}
Utils with IDN: ${libidn}
Use systemd notifications: ${enable_systemd}
Continue with 'make' command"
......@@ -279,6 +279,9 @@ libknotd_la_LIBADD = libknots.la libknot.la
# sbin programs
knotd_LDADD = libknot.la libknotd.la
knotd_CPPFLAGS = ${systemd_daemon_CFLAGS}
knotd_LDFLAGS = ${systemd_daemon_LIBS}
knotc_LDADD = libknot.la libknotd.la
# bin programs
......
......@@ -26,6 +26,10 @@
#include <cap-ng.h>
#endif /* HAVE_CAP_NG_H */
#ifdef ENABLE_SYSTEMD_NOTIFY
#include <systemd/sd-daemon.h>
#endif
#include "libknot/common.h"
#include "libknot/dnssec/crypto.h"
#include "knot/knot.h"
......@@ -42,6 +46,14 @@ static volatile short sig_req_stop = 0;
static volatile short sig_req_reload = 0;
static volatile short sig_stopping = 0;
/** \brief Signal started state to the init system. */
static void init_signal_started(void)
{
#ifdef ENABLE_SYSTEMD_NOTIFY
sd_notify(0, "READY=1");
#endif
}
// atexit() handler for server code
static void knot_crypto_deinit(void)
{
......@@ -347,6 +359,7 @@ int main(int argc, char **argv)
} else {
log_server_info("Server started in foreground, PID = %ld\n",
pid);
init_signal_started();
}
/* Start the event loop. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment