Use sdnotify to inform systemd that daemons are ready
This commit is contained in:
parent
aa84b8caa3
commit
8641dff69b
@ -4,6 +4,8 @@ Requires=rpcbind.service
|
||||
After=syslog.target network.target rpcbind.service
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
NotifyAccess=all
|
||||
EnvironmentFile=-/etc/sysconfig/network
|
||||
EnvironmentFile=-/etc/sysconfig/yppasswdd
|
||||
ExecStartPre=/usr/libexec/yppasswdd-pre-setdomain
|
||||
|
171
ypserv-2.29-sdnotify.patch
Normal file
171
ypserv-2.29-sdnotify.patch
Normal file
@ -0,0 +1,171 @@
|
||||
diff -up ypserv-2.28/configure.in.sdnotify ypserv-2.28/configure.in
|
||||
--- ypserv-2.28/configure.in.sdnotify 2012-07-12 14:29:03.491853939 +0200
|
||||
+++ ypserv-2.28/configure.in 2012-07-12 14:29:03.505854057 +0200
|
||||
@@ -269,6 +269,19 @@ if test "$ac_cv_func_getrpcport" = no; t
|
||||
[ac_cv_func_getrpcport=yes; LIBS="-lrpcsvc $LIBS"])
|
||||
fi
|
||||
|
||||
+USE_SD_NOTIFY=0
|
||||
+AC_SUBST(USE_SD_NOTIFY)
|
||||
+AC_CHECK_LIB(systemd-daemon,sd_notify,LIBSYSTEMD_DAEMON="-lsystemd-daemon",
|
||||
+ LIBSYSTEMD_DAEMON="")
|
||||
+if test -n "$LIBSYSTEMD_DAEMON" ; then
|
||||
+ AC_CHECK_HEADERS(systemd/sd-daemon.h)
|
||||
+ if test "$ac_cv_header_systemd_sd_notify_h" = yes; then
|
||||
+ USE_SD_NOTIFY=1
|
||||
+ fi
|
||||
+fi
|
||||
+AC_SUBST(USE_SD_NOTIFY)
|
||||
+AC_SUBST(LIBSYSTEMD_DAEMON)
|
||||
+
|
||||
AC_CHECK_LIB(nsl,gethostbyname)
|
||||
AC_CHECK_LIB(socket,socket)
|
||||
AC_CHECK_LIB(resolv, res_gethostbyname, RESOLV="-lresolv", RESOLV="")
|
||||
@@ -357,7 +370,7 @@ Configuration:
|
||||
Compiler flags: ${CFLAGS}
|
||||
Preprocessor: ${CPP}
|
||||
Preprocessor flags: ${CPPFLAGS}
|
||||
- Libraries: ${LIBS} ${LIBDBM} ${LIBCRYPT}
|
||||
+ Libraries: ${LIBS} ${LIBDBM} ${LIBCRYPT} ${LIBSYSTEMD_DAEMON}
|
||||
Awk: ${AWK}
|
||||
Shell: ${BASH}
|
||||
NIS map dir: ${YPMAPDIR}
|
||||
diff -up ypserv-2.28/lib/access.c.sdnotify ypserv-2.28/lib/access.c
|
||||
--- ypserv-2.28/lib/access.c.sdnotify 2011-08-31 13:40:11.000000000 +0200
|
||||
+++ ypserv-2.28/lib/access.c 2012-07-12 14:29:03.505854057 +0200
|
||||
@@ -30,6 +30,9 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
+#if defined(HAVE_SYSTEMD_SD_DAEMON_H)
|
||||
+#include <systemd/sd-daemon.h>
|
||||
+#endif
|
||||
|
||||
#include "log_msg.h"
|
||||
#include "ypserv_conf.h"
|
||||
@@ -215,3 +218,25 @@ is_valid (struct svc_req *rqstp, const c
|
||||
|
||||
return status;
|
||||
}
|
||||
+
|
||||
+/* Send a messages to systemd daemon, that inicialization of daemon
|
||||
+ is finished and daemon is ready to accept connections.
|
||||
+ It is a nop if we don't use systemd. */
|
||||
+void
|
||||
+announce_ready()
|
||||
+{
|
||||
+#ifdef USE_SD_NOTIFY
|
||||
+ int result;
|
||||
+
|
||||
+ result = sd_notifyf(0, "READY=1\n"
|
||||
+ "STATUS=Processing requests...\n"
|
||||
+ "MAINPID=%lu", (unsigned long) getpid());
|
||||
+
|
||||
+ /* Return code from sd_notifyf can be ignored, as per sd_notifyf(3).
|
||||
+ However, if we use systemd's native unit file, we need to send
|
||||
+ this message to let systemd know that daemon is ready.
|
||||
+ Thus, we want to know that the call had some issues. */
|
||||
+ if (result < 0)
|
||||
+ log_msg ("sd_notifyf failed: %s\n", strerror(-result));
|
||||
+#endif
|
||||
+}
|
||||
diff -up ypserv-2.28/lib/Makefile.am.sdnotify ypserv-2.28/lib/Makefile.am
|
||||
--- ypserv-2.28/lib/Makefile.am.sdnotify 2010-02-23 14:44:55.000000000 +0100
|
||||
+++ ypserv-2.28/lib/Makefile.am 2012-07-12 14:29:03.506854065 +0200
|
||||
@@ -13,7 +13,8 @@ noinst_HEADERS = log_msg.h yp.h ypserv_c
|
||||
|
||||
rpcsvc_HEADERS = ypxfrd.x
|
||||
|
||||
-DEFS = @DEFS@ -D_REENTRANT=1 -DCONFDIR=\"$(sysconfdir)\" -DUSE_SLP=@USE_SLP@
|
||||
+DEFS = @DEFS@ -D_REENTRANT=1 -DCONFDIR=\"$(sysconfdir)\" -DUSE_SLP=@USE_SLP@ \
|
||||
+ -DUSE_SD_NOTIFY=@USE_SD_NOTIFY@
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_builddir) -I$(srcdir)
|
||||
AM_CFLAGS = @PIE_CFLAGS@
|
||||
|
||||
diff -up ypserv-2.28/rpc.yppasswdd/Makefile.am.sdnotify ypserv-2.28/rpc.yppasswdd/Makefile.am
|
||||
--- ypserv-2.28/rpc.yppasswdd/Makefile.am.sdnotify 2006-08-02 15:05:04.000000000 +0200
|
||||
+++ ypserv-2.28/rpc.yppasswdd/Makefile.am 2012-07-12 14:29:03.506854065 +0200
|
||||
@@ -24,7 +24,7 @@ sbin_PROGRAMS = rpc.yppasswdd
|
||||
|
||||
rpc_yppasswdd_SOURCES = update.c yppasswd_xdr.c yppasswdd.c
|
||||
|
||||
-rpc_yppasswdd_LDADD = @PIE_LDFLAGS@ $(LIBDBM) $(LIBCRYPT) $(top_builddir)/lib/libyp.a
|
||||
+rpc_yppasswdd_LDADD = @PIE_LDFLAGS@ $(LIBDBM) $(LIBCRYPT) $(LIBSYSTEMD_DAEMON) $(top_builddir)/lib/libyp.a
|
||||
rpc_yppasswdd_CFLAGS = @PIE_CFLAGS@
|
||||
|
||||
if ENABLE_REGENERATE_MAN
|
||||
diff -up ypserv-2.28/rpc.yppasswdd/yppasswdd.c.sdnotify ypserv-2.28/rpc.yppasswdd/yppasswdd.c
|
||||
--- ypserv-2.28/rpc.yppasswdd/yppasswdd.c.sdnotify 2012-07-12 14:29:03.494853964 +0200
|
||||
+++ ypserv-2.28/rpc.yppasswdd/yppasswdd.c 2012-07-12 14:29:03.507854073 +0200
|
||||
@@ -457,6 +457,13 @@ main (int argc, char **argv)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
+ /* If we use systemd as an init system, we may want to give it
|
||||
+ a message, that this daemon is ready to accept connections.
|
||||
+ At this time, sockets for receiving connections are already
|
||||
+ created, so we can say we're ready now. It is a nop if we
|
||||
+ don't use systemd. */
|
||||
+ announce_ready();
|
||||
+
|
||||
/* Run the server */
|
||||
svc_run ();
|
||||
log_msg ("svc_run returned\n");
|
||||
diff -up ypserv-2.28/rpc.ypxfrd/Makefile.am.sdnotify ypserv-2.28/rpc.ypxfrd/Makefile.am
|
||||
--- ypserv-2.28/rpc.ypxfrd/Makefile.am.sdnotify 2012-07-12 14:29:42.795191749 +0200
|
||||
+++ ypserv-2.28/rpc.ypxfrd/Makefile.am 2012-07-12 14:30:04.450388983 +0200
|
||||
@@ -22,7 +22,7 @@ sbin_PROGRAMS = rpc.ypxfrd
|
||||
|
||||
rpc_ypxfrd_SOURCES = ypxfrd.c ypxfrd_server.c ypxfrd_svc.c
|
||||
|
||||
-rpc_ypxfrd_LDADD = @PIE_LDFLAGS@ $(top_builddir)/lib/libyp.a @LIBDBM@
|
||||
+rpc_ypxfrd_LDADD = @PIE_LDFLAGS@ $(top_builddir)/lib/libyp.a @LIBDBM@ $(LIBSYSTEMD_DAEMON)
|
||||
rpc_ypxfrd_CFLAGS = @PIE_CFLAGS@
|
||||
|
||||
if ENABLE_REGENERATE_MAN
|
||||
diff -up ypserv-2.28/rpc.ypxfrd/ypxfrd.c.sdnotify ypserv-2.28/rpc.ypxfrd/ypxfrd.c
|
||||
--- ypserv-2.28/rpc.ypxfrd/ypxfrd.c.sdnotify 2012-07-12 14:29:03.496853980 +0200
|
||||
+++ ypserv-2.28/rpc.ypxfrd/ypxfrd.c 2012-07-12 14:29:03.508854082 +0200
|
||||
@@ -458,6 +458,13 @@ main (int argc, char **argv)
|
||||
alarm (_RPCSVC_CLOSEDOWN);
|
||||
}
|
||||
|
||||
+ /* If we use systemd as an init system, we may want to give it
|
||||
+ a message, that this daemon is ready to accept connections.
|
||||
+ At this time, sockets for receiving connections are already
|
||||
+ created, so we can say we're ready now. It is a nop if we
|
||||
+ don't use systemd. */
|
||||
+ announce_ready();
|
||||
+
|
||||
svc_run();
|
||||
log_msg("svc_run returned");
|
||||
unlink (_YPXFRD_PIDFILE);
|
||||
diff -up ypserv-2.28/ypserv/Makefile.am.sdnotify ypserv-2.28/ypserv/Makefile.am
|
||||
--- ypserv-2.28/ypserv/Makefile.am.sdnotify 2009-04-02 15:10:19.000000000 +0200
|
||||
+++ ypserv-2.28/ypserv/Makefile.am 2012-07-12 14:30:15.628494608 +0200
|
||||
@@ -22,7 +22,7 @@ sbin_PROGRAMS = ypserv
|
||||
|
||||
ypserv_SOURCES = ypserv.c server.c ypserv_xdr.c reg_slp.c
|
||||
|
||||
-ypserv_LDADD = @PIE_LDFLAGS@ $(top_builddir)/lib/libyp.a @LIBDBM@ @LIBSLP@
|
||||
+ypserv_LDADD = @PIE_LDFLAGS@ $(top_builddir)/lib/libyp.a @LIBDBM@ @LIBSLP@ $(LIBSYSTEMD_DAEMON)
|
||||
ypserv_CFLAGS = @PIE_CFLAGS@
|
||||
|
||||
if ENABLE_REGENERATE_MAN
|
||||
diff -up ypserv-2.28/ypserv/ypserv.c.sdnotify ypserv-2.28/ypserv/ypserv.c
|
||||
--- ypserv-2.28/ypserv/ypserv.c.sdnotify 2012-07-12 14:29:03.498853997 +0200
|
||||
+++ ypserv-2.28/ypserv/ypserv.c 2012-07-12 14:29:03.509854091 +0200
|
||||
@@ -586,6 +586,13 @@ main (int argc, char **argv)
|
||||
register_slp ();
|
||||
#endif
|
||||
|
||||
+ /* If we use systemd as an init system, we may want to give it
|
||||
+ a message, that this daemon is ready to accept connections.
|
||||
+ At this time, sockets for receiving connections are already
|
||||
+ created, so we can say we're ready now. It is a nop if we
|
||||
+ don't use systemd. */
|
||||
+ announce_ready();
|
||||
+
|
||||
#if 0
|
||||
mysvc_run ();
|
||||
#else
|
@ -4,6 +4,8 @@ Requires=rpcbind.service
|
||||
After=syslog.target network.target rpcbind.service
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
NotifyAccess=all
|
||||
EnvironmentFile=-/etc/sysconfig/network
|
||||
ExecStart=/usr/sbin/ypserv -f $YPSERV_ARGS
|
||||
|
||||
|
@ -32,6 +32,7 @@ Patch8: ypserv-2.24-aliases.patch
|
||||
Patch9: ypserv-2.25-systemd.patch
|
||||
Patch16: ypserv-2.27-confpost.patch
|
||||
Patch17: ypserv-2.27-cloexec.patch
|
||||
Patch18: ypserv-2.29-sdnotify.patch
|
||||
|
||||
BuildRequires: tokyocabinet-devel
|
||||
BuildRequires: systemd-units
|
||||
@ -66,6 +67,7 @@ machines.
|
||||
%patch9 -p1 -b .systemd
|
||||
%patch16 -p1 -b .confpost
|
||||
%patch17 -p1 -b .cloexec
|
||||
%patch18 -p1 -b .sdnotify
|
||||
|
||||
autoreconf
|
||||
|
||||
@ -192,6 +194,7 @@ NOPUSH=true make -eC /var/yp >&2 || :
|
||||
%changelog
|
||||
* Mon Sep 03 2012 Honza Horak <hhorak@redhat.com> - 2.29-1
|
||||
- Update to new upstream version that fix memory leaks (Related: #845283)
|
||||
- Use sdnotify to inform systemd that daemons are ready
|
||||
|
||||
* Sun Jul 22 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.28-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
|
||||
|
@ -4,6 +4,8 @@ Requires=rpcbind.service
|
||||
After=syslog.target network.target rpcbind.service
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
NotifyAccess=all
|
||||
EnvironmentFile=-/etc/sysconfig/network
|
||||
ExecStart=/usr/sbin/rpc.ypxfrd -f $YPXFRD_ARGS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user