Makefile.common | 1 +
configure.ac | 16 ++
contrib/plmc/Makefile.common | 1 +
contrib/plmc/config/plmcd.conf | 4 +
contrib/plmc/configure.ac | 16 ++
contrib/plmc/lib/utils/plmc_read_config.c | 8 +
contrib/plmc/plmcd/Makefile.am | 4 +
contrib/plmc/plmcd/plmcd.c | 52 ++++++++-
contrib/plmc/scripts/Makefile.am | 6 +
contrib/plmc/scripts/plmcboot.service.in | 12 ++
contrib/plmc/scripts/plmcd.service.in | 13 ++
opensaf.spec.in | 70 ++++++++++-
osaf/services/infrastructure/nid/scripts/Makefile.am | 5 +
osaf/services/infrastructure/nid/scripts/opensafd.service.in | 13 ++
14 files changed, 211 insertions(+), 10 deletions(-)
Jun 2 16:55:57 linux-po6q osafrded[16114]: Started
Jun 2 16:55:57 linux-po6q osafrded[16114]: Creation of real-time thread
'OSAF_TMR' FAILED - 'Operation not permitted'
Jun 2 16:55:57 linux-po6q osafrded[16114]: ER ncs_core_agents_startup FAILED
Jun 2 16:55:57 linux-po6q opensafd[16086]: ER Failed
Jun 2 16:55:57 linux-po6q opensafd[16086]: ER Going for recovery
Jun 2 16:55:57 linux-po6q opensafd[16086]: ER Trying To RESPAWN
/usr/lib64/opensaf/clc-cli/osaf-rded attempt #1
Jun 2 16:55:57 linux-po6q opensafd[16086]: ER Sending SIGKILL to RDE, pid=16106
Jun 2 16:55:57 linux-po6q osafrded[16114]: Exiting...
Jun 2 16:56:12 linux-po6q osafrded[16133]: Started
Linux distros that use systemd fail to start opensafd because, by default,
systemd does not assign any RT time budgets to the "cpu" cgroups it creates.
The solution is in two parts: (1) Create an opensafd.service file for use by
systemd which has cgroup info in it. (2) Make plmcd a full systemd-enabled
daemon.
diff --git a/Makefile.common b/Makefile.common
--- a/Makefile.common
+++ b/Makefile.common
@@ -31,5 +31,6 @@ docdir = $(datadir)/doc/$(PACKAGE_NAME)-
javadir = $(datadir)/java
javadocdir = $(datadir)/javadoc
lsbinitdir = $(initscriptdir)
+systemddir = $(systemdsystemunitdir)
lockdir = $(localstatedir)/lock/subsys
pkgpyosafdir = $(pythondir)/pyosaf
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -245,6 +245,20 @@ fi
AM_CONDITIONAL([ENABLE_TIPC_TRANSPORT], [test "$enable_tipc" = yes])
AC_SUBST([TIPC_TRANSPORT_ENABLED], ["$enable_tipc"])
+#
+# Enable/disable use of systemd
+#
+PKG_CHECK_MODULES([SYSTEMD], [systemd], [enable_systemd=yes],
[enable_systemd=no])
+
+if test "$enable_systemd" = yes; then
+ PKG_CHECK_MODULES([SYSTEMD], [systemd])
+ AC_DEFINE([ENABLE_SYSTEMD], 1, [Define if systemd is enabled])
+ systemdunitdir=$(pkg-config --variable=systemdsystemunitdir systemd)
+fi
+
+AM_CONDITIONAL([ENABLE_SYSTEMD], [test "$enable_systemd" = yes])
+AC_SUBST([SYSTEMD_ENABLED], ["$enable_systemd"])
+AC_SUBST([systemdsystemunitdir], ["$systemdunitdir"])
#
# Enable/disable building the OpenSAF tests
@@ -769,6 +783,7 @@ AC_CONFIG_FILES([
osaf/services/infrastructure/nid/scripts/Makefile
osaf/services/infrastructure/nid/scripts/configure_tipc
osaf/services/infrastructure/nid/scripts/opensafd
+ osaf/services/infrastructure/nid/scripts/opensafd.service
osaf/services/infrastructure/rde/Makefile
osaf/services/infrastructure/rde/include/Makefile
osaf/services/infrastructure/rde/scripts/Makefile
@@ -960,5 +975,6 @@ echo "${ECHO_T} Enable Java AIS Mapping
echo "${ECHO_T} Enable AM4J: ${enable_am4j}"
echo "${ECHO_T} Enable PLM support: ${enable_ais_plm}"
echo "${ECHO_T} Enable TIPC transport: ${enable_tipc}"
+echo "${ECHO_T} Enable systemd: ${enable_systemd}"
echo "======================================================="
echo ""
diff --git a/contrib/plmc/Makefile.common b/contrib/plmc/Makefile.common
--- a/contrib/plmc/Makefile.common
+++ b/contrib/plmc/Makefile.common
@@ -2,4 +2,5 @@ AM_CPPFLAGS = $(all_includes)
AM_CFLAGS = -fPIC -Wall
#AM_CFLAGS = -fPIC -Wall -Werror
+systemddir = $(systemdsystemunitdir)
lsbinitdir = $(initscriptdir)
diff --git a/contrib/plmc/config/plmcd.conf b/contrib/plmc/config/plmcd.conf
--- a/contrib/plmc/config/plmcd.conf
+++ b/contrib/plmc/config/plmcd.conf
@@ -72,6 +72,8 @@ 10.105.1.6
# Also note that you will need to manually remove any references to these
# init scripts in the rc directories for OpenSAF to fully control the
# startup and stop of the services
+# If using systemd this should be the service name (e.g. snmpd.service)
+# instead of the SysVInit script
# Optional
[services]
/etc/init.d/snmpd
@@ -84,6 +86,8 @@ 10.105.1.6
# Note that on a controller there should still be references to the
# /etc/init.d/opensafd script in the rc directories for the service to
# startup initially. Without this OpenSAF will never start
+# If using systemd this should be the service name (e.g. opensafd.service)
+# instead of the SysVInit script
# Optional
[osaf]
/etc/init.d/opensafd
diff --git a/contrib/plmc/configure.ac b/contrib/plmc/configure.ac
--- a/contrib/plmc/configure.ac
+++ b/contrib/plmc/configure.ac
@@ -47,6 +47,20 @@ AC_CONFIG_COMMANDS([libtool-rpath-patch]
fi],
[libtool_patch_use_rpath=$enable_rpath])
+#
+# Enable/disable use of systemd
+#
+PKG_CHECK_MODULES([SYSTEMD], [systemd], [enable_systemd=yes],
[enable_systemd=no])
+
+if test "$enable_systemd" = yes; then
+ PKG_CHECK_MODULES([SYSTEMD], [systemd])
+ AC_DEFINE([ENABLE_SYSTEMD], 1, [Define if systemd is enabled])
+ systemdunitdir=$(pkg-config --variable=systemdsystemunitdir systemd)
+fi
+
+AM_CONDITIONAL([ENABLE_SYSTEMD], [test "$enable_systemd" = yes])
+AC_SUBST([SYSTEMD_ENABLED], ["$enable_systemd"])
+AC_SUBST([systemdsystemunitdir], ["$systemdunitdir"])
#
# Many distros use different init.d directory depending on their LSB compliance
@@ -138,6 +152,8 @@ AC_CONFIG_FILES([ \
lib/utils/Makefile \
plmcd/Makefile \
scripts/Makefile \
+ scripts/plmcboot.service \
+ scripts/plmcd.service \
scripts/plmcboot \
scripts/plmcd])
diff --git a/contrib/plmc/lib/utils/plmc_read_config.c
b/contrib/plmc/lib/utils/plmc_read_config.c
--- a/contrib/plmc/lib/utils/plmc_read_config.c
+++ b/contrib/plmc/lib/utils/plmc_read_config.c
@@ -26,6 +26,10 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -187,6 +191,7 @@ int plmc_read_config(char *plmc_config_f
tag = 0;
break;
case PLMC_SERVICES:
+#if (ENABLE_SYSTEMD == 0)
if (checkfile(line)) {
syslog(LOG_ERR, "plmc_read_"
"config.c: Service "
@@ -195,6 +200,7 @@ int plmc_read_config(char *plmc_config_f
line);
return -1;
}
+#endif
strncpy(config->services[num_services],
line, PLMC_MAX_TAG_LEN -1);
num_services++;
@@ -212,6 +218,7 @@ int plmc_read_config(char *plmc_config_f
}
break;
case PLMC_OSAF:
+#if (ENABLE_SYSTEMD == 0)
if (checkfile(line)) {
syslog(LOG_ERR, "plmc_read_"
"config.c: Osaf "
@@ -220,6 +227,7 @@ int plmc_read_config(char *plmc_config_f
line);
return -1;
}
+#endif
strncpy(config->osaf, line,
PLMC_MAX_TAG_LEN -1);
tag = 0;
diff --git a/contrib/plmc/plmcd/Makefile.am b/contrib/plmc/plmcd/Makefile.am
--- a/contrib/plmc/plmcd/Makefile.am
+++ b/contrib/plmc/plmcd/Makefile.am
@@ -31,5 +31,9 @@ plmcd_SOURCES = \
plmcd_LDFLAGS = -lpthread
+if ENABLE_SYSTEMD
+plmcd_LDFLAGS += -lsystemd-daemon
+endif
+
plmcd_LDADD = \
$(top_builddir)/lib/utils/libplmc_utils.la
diff --git a/contrib/plmc/plmcd/plmcd.c b/contrib/plmc/plmcd/plmcd.c
--- a/contrib/plmc/plmcd/plmcd.c
+++ b/contrib/plmc/plmcd/plmcd.c
@@ -31,6 +31,10 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
@@ -54,6 +58,10 @@
#include <arpa/inet.h>
+#if (ENABLE_SYSTEMD == 1)
+#include <systemd/sd-daemon.h>
+#endif
+
#include "plmc.h"
#include "plmc_cmds.h"
@@ -135,37 +143,65 @@ void *plmc_child_thread(void *arg)
case PLMC_SA_PLM_ADMIN_UNLOCK_CMD:
/* Unlock the OS - start OpenSAF-related services, then
start OpenSAF. */
for(i=0; i<config.num_services; i++) {
+#if (ENABLE_SYSTEMD == 1)
+ tmp_retval = sysexec("/bin/systemctl start",
config.services[i]);
+#else
tmp_retval = sysexec(config.services[i],
"start");
+#endif
if (tmp_retval) retval = tmp_retval;
}
+#if (ENABLE_SYSTEMD == 1)
+ tmp_retval = sysexec("/bin/systemctl start",
config.osaf);
+#else
tmp_retval = sysexec(config.osaf, "start");
+#endif
if (tmp_retval) retval = tmp_retval;
break;
case PLMC_SA_PLM_ADMIN_LOCK_CMD:
/* Lock the OS - stop OpenSAF, then stop
OpenSAF-related services. */
+#if (ENABLE_SYSTEMD == 1)
+ tmp_retval = sysexec("/bin/systemctl stop",
config.osaf);
+#else
tmp_retval = sysexec(config.osaf, "stop");
+#endif
if (tmp_retval) retval = tmp_retval;
for(i = config.num_services -1; i >= 0; i--) {
+#if (ENABLE_SYSTEMD == 1)
+ tmp_retval = sysexec("/bin/systemctl stop",
config.services[i]);
+#else
tmp_retval = sysexec(config.services[i],
"stop");
+#endif
if (tmp_retval) retval = tmp_retval;
}
break;
case PLMC_OSAF_START_CMD:
/* Start OpenSAF. */
+#if (ENABLE_SYSTEMD == 1)
+ retval = sysexec("/bin/systemctl start", config.osaf);
+#else
retval = sysexec(config.osaf, "start");
+#endif
break;
case PLMC_OSAF_STOP_CMD:
/* Stop OpenSAF. */
+#if (ENABLE_SYSTEMD == 1)
+ retval = sysexec("/bin/systemctl stop", config.osaf);
+#else
retval = sysexec(config.osaf, "stop");
+#endif
break;
case PLMC_OSAF_SERVICES_START_CMD:
/* Start OpenSAF-related services. */
for(i=0; i<config.num_services; i++) {
+#if (ENABLE_SYSTEMD == 1)
+ tmp_retval = sysexec("/bin/systemctl start",
config.services[i]);
+#else
tmp_retval = sysexec(config.services[i],
"start");
+#endif
if (tmp_retval) retval = tmp_retval;
}
break;
@@ -173,7 +209,11 @@ void *plmc_child_thread(void *arg)
case PLMC_OSAF_SERVICES_STOP_CMD:
/* Stop OpenSAF-related services. */
for(i = config.num_services -1; i >= 0; i--) {
+#if (ENABLE_SYSTEMD == 1)
+ tmp_retval = sysexec("/bin/systemctl stop",
config.services[i]);
+#else
tmp_retval = sysexec(config.services[i],
"stop");
+#endif
if (tmp_retval) retval = tmp_retval;
}
break;
@@ -625,7 +665,10 @@ int main(int argc, char** argv)
int tcp_keepidle_time, tcp_keepalive_intvl, tcp_keepalive_probes;
int so_keepalive;
socklen_t optlen;
- int controller = 1, time = 1, pid=0;
+ int controller = 1, time = 1;
+#if (ENABLE_SYSTEMD == 0)
+ int pid=0;
+#endif
struct sockaddr_in sin;
unsigned int option= 0x0;
@@ -710,6 +753,7 @@ int main(int argc, char** argv)
usage(basename(argv[0]));
}
+#if (ENABLE_SYSTEMD == 0)
/* Check the lock file to make sure we are not already runing */
if ((pid=chkpid(PLMCD_PID))){
fprintf(stderr, "plmcd already running? %d\n", pid);
@@ -724,15 +768,18 @@ int main(int argc, char** argv)
syslog(LOG_ERR, "Error, daemon: %m");
exit(PLMC_EXIT_FAILURE);
}
+#endif
umask(027);
+#if (ENABLE_SYSTEMD == 0)
/* write a PID file */
/* Check the lock file to make sure we are not already runing */
if (!writepid(PLMCD_PID)){
syslog(LOG_ERR, "Error, can not create pid file %s", PLMCD_PID);
exit(PLMC_EXIT_FAILURE);
}
+#endif
/* Set up termination signal handler here. */
@@ -741,6 +788,9 @@ int main(int argc, char** argv)
/* Send UDP datagram that the EE has instantiated. */
plmc_send_udp_msg(PLMC_D_START_MSG);
+#if (ENABLE_SYSTEMD == 1)
+ sd_notify(0, "READY=1");
+#endif
/* Attempts to establish a connection to a PLM server. If the connection
* to controller 1 fails or times out try to connect to conrtoller 2. If
diff --git a/contrib/plmc/scripts/Makefile.am b/contrib/plmc/scripts/Makefile.am
--- a/contrib/plmc/scripts/Makefile.am
+++ b/contrib/plmc/scripts/Makefile.am
@@ -18,6 +18,12 @@ include $(top_srcdir)/Makefile.common
MAINTAINERCLEANFILES = Makefile.in
+if ENABLE_SYSTEMD
+nodist_systemd_SCRIPTS = \
+ $(top_builddir)/scripts/plmcboot.service \
+ $(top_builddir)/scripts/plmcd.service
+else
nodist_lsbinit_SCRIPTS = \
$(top_builddir)/scripts/plmcboot \
$(top_builddir)/scripts/plmcd
+endif
diff --git a/contrib/plmc/scripts/plmcboot.service.in
b/contrib/plmc/scripts/plmcboot.service.in
new file mode 100644
--- /dev/null
+++ b/contrib/plmc/scripts/plmcboot.service.in
@@ -0,0 +1,12 @@
+[Unit]
+Description=Send a UDP datagram to OpenSAF PLM controllers indicating the OS
state
+After=syslog.target network.target
+
+[Service]
+ExecStart=@sbindir@/plmcd -c @sysconfdir@/plmcd.conf -s
+ExecStop=@sbindir@/plmcd -c @sysconfdir@/plmcd.conf -x
+Type=oneshot
+RemainAfterExit=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/contrib/plmc/scripts/plmcd.service.in
b/contrib/plmc/scripts/plmcd.service.in
new file mode 100644
--- /dev/null
+++ b/contrib/plmc/scripts/plmcd.service.in
@@ -0,0 +1,13 @@
+[Unit]
+Description=OpenSAF PLMC Daemon
+After=syslog.target network.target plmcboot.service
+Wants=plmcboot.service
+
+[Service]
+ExecStart=@sbindir@/plmcd -c @sysconfdir@/plmcd.conf
+Type=notify
+Restart=always
+NotifyAccess=main
+
+[Install]
+WantedBy=multi-user.target
diff --git a/opensaf.spec.in b/opensaf.spec.in
--- a/opensaf.spec.in
+++ b/opensaf.spec.in
@@ -15,6 +15,18 @@
%define is_ais_msg %(test "@AIS_MSG_ENABLED@" = "yes" && echo 1 || echo 0)
%define is_ais_smf %(test "@AIS_SMF_ENABLED@" = "yes" && echo 1 || echo 0)
+%if 0%{?suse_version} >= 1210
+%define use_systemd 1
+%define _systemd_preun() %{service_del_preun}
+%define _systemd_post() %{service_add_post}
+%endif
+
+%if 0%{?fedora} >= 18
+%define use_systemd 1
+%define _systemd_preun() %{systemd_preun}
+%define _systemd_post() %{systemd_post}
+%endif
+
%define _pkglibdir %{_libdir}/%{name}
%define _pkgsysconfdir %{_sysconfdir}/%{name}
%define _initddir @initscriptdir@
@@ -42,9 +54,15 @@ URL: http://www.opensaf.org
Source: http://download.opensaf.org/releases/%{name}-%{version}.tar.gz
Packager: @OPENSAF_BUGREPORT@
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+%if %use_systemd
+BuildRequires: systemd
+%systemd_requires
+%endif
Requires(pre): /usr/bin/getent /usr/sbin/groupadd /usr/sbin/useradd
+%if ! %use_systemd
Requires(post): /usr/lib/lsb/install_initd /sbin/service
Requires(preun): /usr/lib/lsb/remove_initd /sbin/service
+%endif
Requires: /lib/lsb/init-functions
Requires: %{name}-libs = %{version}-%{release}
@@ -391,6 +409,10 @@ running on the System Controller nodes o
%package plm-coordinator
Group: System Environment/Daemons
Summary: The OpenSAF implementation of the SAF-AIS-PLM Service
+%if %use_systemd
+BuildRequires: systemd-devel
+%systemd_requires
+%endif
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
Requires: /lib/lsb/init-functions
@@ -756,17 +778,29 @@ exit 0
%post
# $1 == 1 (install), $1 == 2 (upgrade)
if [ $1 -gt 1 ]; then
- /sbin/service opensafd try-restart >/dev/null 2>&1 || :
+ %if %use_systemd
+ /bin/systemctl try-restart opensafd.service
+ %else
+ /sbin/service opensafd try-restart >/dev/null 2>&1 || :
+ %endif
else
- /usr/lib/lsb/install_initd %{_initddir}/opensafd
+ %if %use_systemd
+ %_systemd_post opensafd.service
+ %else
+ /usr/lib/lsb/install_initd %{_initddir}/opensafd
+ %endif
fi
%preun
# $1 == 1 (upgrade), $1 == 0, (uninstall)
if [ $1 = 0 ]; then
- /sbin/service opensafd stop >/dev/null 2>&1 || :
- /usr/lib/lsb/remove_initd %{_initddir}/opensafd
- sed -i '/%{opensaf_user}/d' /etc/sudoers
+ %if %use_systemd
+ %_systemd_preun opensafd.service
+ %else
+ /sbin/service opensafd stop >/dev/null 2>&1 || :
+ /usr/lib/lsb/remove_initd %{_initddir}/opensafd
+ sed -i '/%{opensaf_user}/d' /etc/sudoers
+ %endif
fi
%post amf-libs -p /sbin/ldconfig
@@ -782,15 +816,25 @@ fi
if [ $1 -gt 1 ]; then
echo "" >/dev/null 2>&1 || :
else
- /usr/lib/lsb/install_initd %{_initddir}/plmcboot
- /usr/lib/lsb/install_initd %{_initddir}/plmcd
+ %if %use_systemd
+ %_systemd_post plmcboot.service
+ %_systemd_post plmcd.service
+ %else
+ /usr/lib/lsb/install_initd %{_initddir}/plmcboot
+ /usr/lib/lsb/install_initd %{_initddir}/plmcd
+ %endif
fi
%preun plm-coordinator
# $1 == 1 (upgrade), $1 == 0, (uninstall)
if [ $1 = 0 ]; then
- /usr/lib/lsb/remove_initd %{_initddir}/plmcboot
- /usr/lib/lsb/remove_initd %{_initddir}/plmcd
+ %if %use_systemd
+ %_systemd_preun plmcboot.service
+ %_systemd_preun plmcd.service
+ %else
+ /usr/lib/lsb/remove_initd %{_initddir}/plmcboot
+ /usr/lib/lsb/remove_initd %{_initddir}/plmcd
+ %endif
fi
%endif
@@ -895,6 +939,9 @@ fi
%config(noreplace) %{_pkgsysconfdir}/node_name
%config %{_pkgsysconfdir}/osafdir.conf
%config %{_pkgsysconfdir}/nid.conf
+%if %use_systemd
+%config %_unitdir/opensafd.service
+%endif
%config %{_initddir}/opensafd
%{_pkglibdir}/opensafd
%{_pkglibdir}/opensaf_reboot
@@ -1125,8 +1172,13 @@ fi
%config(noreplace) %{_sysconfdir}/plmcd.conf
%{_sbindir}/plmcd
%{_libdir}/libplmc_utils.so.*
+%if %use_systemd
+%_unitdir/plmcboot.service
+%_unitdir/plmcd.service
+%else
%{_initddir}/plmcboot
%{_initddir}/plmcd
+%endif
%files plm-hpi
%defattr(-,root,root)
diff --git a/osaf/services/infrastructure/nid/scripts/Makefile.am
b/osaf/services/infrastructure/nid/scripts/Makefile.am
--- a/osaf/services/infrastructure/nid/scripts/Makefile.am
+++ b/osaf/services/infrastructure/nid/scripts/Makefile.am
@@ -22,5 +22,10 @@ osaf_execbindir = $(pkglibdir)
nodist_osaf_execbin_SCRIPTS = \
$(top_builddir)/osaf/services/infrastructure/nid/scripts/configure_tipc
+if ENABLE_SYSTEMD
+dist_systemd_SCRIPTS = \
+
$(top_builddir)/osaf/services/infrastructure/nid/scripts/opensafd.service
+endif
+
dist_lsbinit_SCRIPTS = \
$(top_builddir)/osaf/services/infrastructure/nid/scripts/opensafd
diff --git a/osaf/services/infrastructure/nid/scripts/opensafd.service.in
b/osaf/services/infrastructure/nid/scripts/opensafd.service.in
new file mode 100644
--- /dev/null
+++ b/osaf/services/infrastructure/nid/scripts/opensafd.service.in
@@ -0,0 +1,13 @@
+[Unit]
+Description=OpenSAF daemon
+After=syslog.target network.target
+
+[Service]
+ExecStart=@initscriptdir@/opensafd start
+ExecStop=@initscriptdir@/opensafd stop
+Type=forking
+PIDFile=@localstatedir@/run/opensaf/osafamfnd.pid
+ControlGroup=cpu:/
+
+[Install]
+WantedBy=multi-user.target
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel