/etc/init.d/opensmd: Improve systemd integration
PATCH 3/4 /etc/init.d/opensmd: Improve systemd integration
On recent SLES and openSUSE systems it is necessary to read the file /lib/lsb/init-functions instead of /etc/rc.status for proper integration with systemd. Certain implementations of killproc need a pidfile so make sure that one gets created. Also, correct the opensm service dependency list.
--- configure.in | 6 ++++++ scripts/opensm.init.in | 26 ++++++++++++++++++-------- scripts/redhat-opensm.init.in | 2 ++ 3 files changed, 26 insertions(+), 8 deletions(-)
configure.in +6 -0
@@ -11,6 +11,12 @@ AM_INIT_AUTOMAKE AC_SUBST(RELEASE, ${RELEASE:-unknown}) AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz}) +default_rdma_service=openibd +AC_ARG_WITH([rdma_service], + AC_HELP_STRING([--with-rdma-service=name], + [name of the RDMA service: "rdma" when using /etc/init.d/rdma to start RDMA services; "openibd" when using /etc/init.d/openibd to start RDMA services [default=${default_rdma_service}]])) +AC_SUBST(RDMA_SERVICE, ${with_rdma_service:-${default_rdma_service}}) + if { rpm -q sles-release || rpm -q openSUSE-release; } >/dev/null 2>&1; then default_start="2 3 5" default_stop="0 1 4 6"
scripts/opensm.init.in +18 -8
@@ -7,8 +7,8 @@ # ### BEGIN INIT INFO # Provides: opensm -# Required-Start: $syslog -# Required-Stop: +# Required-Start: $syslog @RDMA_SERVICE@ +# Required-Stop: $syslog @RDMA_SERVICE@ # Default-Start: @DEFAULT_START@ # Default-Stop: @DEFAULT_STOP@ # Description: Manage OpenSM
@@ -42,14 +42,22 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +pidfile=/var/run/opensm.pid # Source function library. if [[ -s /etc/init.d/functions ]]; then + # RHEL / CentOS / SL / Fedora. . /etc/init.d/functions rc_status() { :; } rc_exit() { exit $RETVAL; } -fi -if [[ -s /etc/rc.status ]]; then +elif [[ -s /lib/lsb/init-functions ]]; then + # SLES / openSuSE / Debian. + . /lib/lsb/init-functions + rc_exit() { exit $RETVAL; } + success() { log_success_msg; } + failure() { log_failure_msg; } +elif [[ -s /etc/rc.status ]]; then + # Older SuSE systems. . /etc/rc.status failure() { rc_status -v; } success() { rc_status -v; }
@@ -61,10 +69,13 @@ if [[ -s $CONFIG ]]; then fi start () { + if [ -e $pidfile ]; then + echo Already started + return 1 + fi echo -n "Starting opensm: " - @sbindir@/opensm --daemon $OPTIONS > /dev/null + @sbindir@/opensm --daemon --pidfile $pidfile $OPTIONS > /dev/null if [[ $RETVAL -eq 0 ]]; then - touch /var/lock/subsys/opensm success else failure
@@ -76,7 +87,6 @@ stop () { echo -n "Shutting down opensm: " killproc opensm if [[ $RETVAL -eq 0 ]]; then - rm -f /var/lock/subsys/opensm success else failure
@@ -114,7 +124,7 @@ case "$1" in restart ;; try-restart | condrestart) - [ -e /var/lock/subsys/opensm ] && restart + [ -e $pidfile ] && restart ;; resweep) killall -HUP opensm
scripts/redhat-opensm.init.in +2 -0
@@ -7,6 +7,8 @@ # ### BEGIN INIT INFO # Provides: opensm +# Required-Start: $syslog @RDMA_SERVICE@ +# Required-Stop: $syslog @RDMA_SERVICE@ # Default-Start: @DEFAULT_START@ # Default-Stop: @DEFAULT_STOP@ # Description: Manage OpenSM
Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Bart,
Quoted 19 lines · Bart Van Assche
On recent SLES and openSUSE systems it is necessary to read the file
/lib/lsb/init-functionsinstead of/etc/rc.statusfor proper integration with systemd. Certain implementations of killproc need a pidfile so make sure that one gets created. Also, correct the opensm service dependency list.Signed-off-by Bart Van Assche <[email protected]>Cc Doug Ledford <[email protected]>--- configure.in | 6 ++++++ scripts/opensm.init.in | 26 ++++++++++++++++++-------- scripts/redhat-opensm.init.in | 2 ++ 3 files changed, 26 insertions(+), 8 deletions(-)configure.in +0
-0
configure.in AM_INIT_AUTOMAKE · line 19
Quoted 9 lines
configure.in +6
-0@@ -11,6 +11,12 @@ AM_INIT_AUTOMAKE AC_SUBST(RELEASE, ${RELEASE:-unknown}) AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz}) +default_rdma_service=openibd +AC_ARG_WITH([rdma_service], + AC_HELP_STRING([--with-rdma-service=name], + [name of the RDMA service: "rdma" when using /etc/init.d/rdma to start RDMA services; "openibd" when using /etc/init.d/openibd to start RDMA services [default=${default_rdma_service}]])) +AC_SUBST(RDMA_SERVICE, ${with_rdma_service:-${default_rdma_service}}) +
There is also an option to run opensm with ibsim. In that case neither rdma nor openibd should run.
Quoted 44 lines
configure.in +0
-0if { rpm -q sles-release || rpm -q openSUSE-release; } >/dev/null 2>&1; then default_start="2 3 5" default_stop="0 1 4 6"scripts/opensm.init.in +12
-4@@ -7,8 +7,8 @@ # ### BEGIN INIT INFO # Provides: opensm -# Required-Start: $syslog -# Required-Stop: +# Required-Start: $syslog @RDMA_SERVICE@ +# Required-Stop: $syslog @RDMA_SERVICE@ # Default-Start: @DEFAULT_START@ # Default-Stop: @DEFAULT_STOP@ # Description: Manage OpenSM@@ -42,14 +42,22 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +pidfile=/var/run/opensm.pid # Source function library. if [[ -s /etc/init.d/functions ]]; then + # RHEL / CentOS / SL / Fedora. . /etc/init.d/functions rc_status() { :; } rc_exit() { exit $RETVAL; } -fi -if [[ -s /etc/rc.status ]]; then +elif [[ -s /lib/lsb/init-functions ]]; then + # SLES / openSuSE / Debian. + . /lib/lsb/init-functions + rc_exit() { exit $RETVAL; } + success() { log_success_msg; } + failure() { log_failure_msg; } +elif [[ -s /etc/rc.status ]]; then + # Older SuSE systems. . /etc/rc.status failure() { rc_status -v; } success() { rc_status -v; }
scripts/opensm.init.in if [[ -s $CONFIG ]]; then · line 72
Quoted 4 lines
scripts/opensm.init.in +1
-0@@ -61,10 +69,13 @@ if [[ -s $CONFIG ]]; then fi start () { + if [ -e $pidfile ]; then
On opensm segfault (happens one in a while :), pidfile won't be removed, so you won't be able to start the opensm again. I guess that same thing can happen on warm reboot.
scripts/opensm.init.in if [[ -s $CONFIG ]]; then · line 75
Quoted 3 lines
scripts/opensm.init.in +3
-0+ echo Already started + return 1 + fi
-- Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 25 lines · Alex Netes
Hi Bart,
Quoted 22 lines · Bart Van Assche
On recent SLES and openSUSE systems it is necessary to read the file
/lib/lsb/init-functionsinstead of/etc/rc.statusfor proper integration with systemd. Certain implementations of killproc need a pidfile so make sure that one gets created. Also, correct the opensm service dependency list.Signed-off-by Bart Van Assche <[email protected]>Cc Doug Ledford <[email protected]>--- configure.in | 6 ++++++ scripts/opensm.init.in | 26 ++++++++++++++++++-------- scripts/redhat-opensm.init.in | 2 ++ 3 files changed, 26 insertions(+), 8 deletions(-)configure.in +0
-0@@ -11,6 +11,12 @@ AM_INIT_AUTOMAKE AC_SUBST(RELEASE, ${RELEASE:-unknown}) AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz})
Quoted 9 lines
configure.in AM_INIT_AUTOMAKE · line 19
Quoted 6 lines
configure.in +6
-0+default_rdma_service=openibd +AC_ARG_WITH([rdma_service], + AC_HELP_STRING([--with-rdma-service=name], + [name of the RDMA service: "rdma" when using /etc/init.d/rdma to start RDMA services; "openibd" when using /etc/init.d/openibd to start RDMA services [default=${default_rdma_service}]])) +AC_SUBST(RDMA_SERVICE, ${with_rdma_service:-${default_rdma_service}}) +There is also an option to run opensm with ibsim. In that case neither rdma nor openibd should run.
ibsim is unlikely to be used by end users or system administrators in a normal startup environment. I doubt it needs to be accounted for in the init script. Most users simply don't even know enough about ibsim to be able to use it at all.
Quoted 46 lines
Quoted 46 lines
configure.in +0
-0if { rpm -q sles-release || rpm -q openSUSE-release; } >/dev/null 2>&1; then default_start="2 3 5" default_stop="0 1 4 6"scripts/opensm.init.in +12
-4@@ -7,8 +7,8 @@ # ### BEGIN INIT INFO # Provides: opensm -# Required-Start: $syslog -# Required-Stop: +# Required-Start: $syslog @RDMA_SERVICE@ +# Required-Stop: $syslog @RDMA_SERVICE@ # Default-Start: @DEFAULT_START@ # Default-Stop: @DEFAULT_STOP@ # Description: Manage OpenSM@@ -42,14 +42,22 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +pidfile=/var/run/opensm.pid # Source function library. if [[ -s /etc/init.d/functions ]]; then + # RHEL / CentOS / SL / Fedora. . /etc/init.d/functions rc_status() { :; } rc_exit() { exit $RETVAL; } -fi -if [[ -s /etc/rc.status ]]; then +elif [[ -s /lib/lsb/init-functions ]]; then + # SLES / openSuSE / Debian. + . /lib/lsb/init-functions + rc_exit() { exit $RETVAL; } + success() { log_success_msg; } + failure() { log_failure_msg; } +elif [[ -s /etc/rc.status ]]; then + # Older SuSE systems. . /etc/rc.status failure() { rc_status -v; } success() { rc_status -v; }@@ -61,10 +69,13 @@ if [[ -s $CONFIG ]]; then fi
Quoted 6 lines
scripts/opensm.init.in if [[ -s $CONFIG ]]; then · line 72
Quoted 2 lines
scripts/opensm.init.in +1
-0start () { + if [ -e $pidfile ]; thenOn opensm segfault (happens one in a while :), pidfile won't be removed, so you won't be able to start the opensm again. I guess that same thing can happen on warm reboot.
The stop action in the script should handle cleanup for you. If it's called, and a pid file exists, but the pid is not running, it should remove the pid file and the subsystem lock file so that a clean start works.
Quoted 10 lines
scripts/opensm.init.in if [[ -s $CONFIG ]]; then · line 75
Quoted 3 lines
scripts/opensm.init.in +3
-0+ echo Already started + return 1 + fi-- Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 6 lines
Doug Ledford <[email protected]> GPG KeyID: 0E572FDD http://people.redhat.com/dledford Infiniband specific RPMs available at http://people.redhat.com/dledford/Infiniband
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Doug Ledford
Quoted 4 lines · Alex Netes
Quoted 2 lines · Bart Van Assche
start () {
+ if [ -e $pidfile ]; then
Quoted 7 lines
Quoted 3 lines
On opensm segfault (happens one in a while :), pidfile won't be removed, so you won't be able to start the opensm again. I guess that same thing can happen on warm reboot.
The stop action in the script should handle cleanup for you. If it's called, and a pid file exists, but the pid is not running, it should remove the pid file and the subsystem lock file so that a clean start works.
Hello Doug,
Do we really need the lock file ? On some Linux systems (Ubuntu) the /var/lock/subsys directory does not even exist.
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 16 lines · Bart Van Assche
Quoted 10 lines · Doug Ledford
Quoted 8 lines · Alex Netes
Quoted 2 lines · Bart Van Assche
start () {
+ if [ -e $pidfile ]; thenOn opensm segfault (happens one in a while :), pidfile won't be removed, so
you won't be able to start the opensm again. I guess that same thing can happen on warm reboot.Quoted 4 lines
The stop action in the script should handle cleanup for you. If it's called, and a pid file exists, but the pid is not running, it should remove the pid file and the subsystem lock file so that a clean start works.
Quoted 7 lines
Hello Doug,
Do we really need the lock file ? On some Linux systems (Ubuntu) the
/var/lock/subsysdirectory does not even exist.Bart.
It's an old holdover from LSB compliance. *I* don't personally care one way or another, but it's supposed to be there for ancient scripts that look there to find out if a service is running. Probably none of those ancient scripts look for opensm as it wasn't around back when they were written and the "new and improved" way of checking a service in LSB is to run the init script with the status command. But, that's why I have it there.
Signature · 6 lines
Doug Ledford <[email protected]> GPG KeyID: 0E572FDD http://people.redhat.com/dledford Infiniband specific RPMs available at http://people.redhat.com/dledford/Infiniband
Quoted 10 lines · Alex Netes
Review
Quoted 6 lines · Bart Van Assche
(quoted diff) +6
-0+default_rdma_service=openibd +AC_ARG_WITH([rdma_service], + AC_HELP_STRING([--with-rdma-service=name], + [name of the RDMA service: "rdma" when using /etc/init.d/rdma to start RDMA services; "openibd" when using /etc/init.d/openibd to start RDMA services [default=${default_rdma_service}]])) +AC_SUBST(RDMA_SERVICE, ${with_rdma_service:-${default_rdma_service}}) +There is also an option to run opensm with ibsim. In that case neither rdma nor openibd should run.
Does running opensm with ibsim require to preload libumad2sim ? If so, that's something that's not supported by the current opensm init script, isn't it ? If that is correct then it looks fine to me to make the dependence on the openibd/rdma service explicit in the opensm startup script.
Quoted 10 lines
Quoted 2 lines
start () {
+ if [ -e $pidfile ]; thenOn opensm segfault (happens one in a while :), pidfile won't be removed, so you won't be able to start the opensm again. I guess that same thing can happen on warm reboot.
Review
Quoted 3 lines
(quoted diff) +3
-0+ echo Already started + return 1 + fi
Good catch. I'll start testing the additional changes below:
scripts/opensm.init.in +8 -2
@@ -68,12 +68,18 @@ if [[ -s $CONFIG ]]; then . $CONFIG fi +running () { + test -e $pidfile && + test "$(readlink "/proc/$(cat $pidfile)/exe")" = "@sbindir@/opensm" +} + start () { - if [ -e $pidfile ]; then + if running; then echo Already started return 1 fi echo -n "Starting opensm: " + rm -f $pidfile @sbindir@/opensm --daemon --pidfile $pidfile $OPTIONS > /dev/null if [[ $RETVAL -eq 0 ]]; then success
@@ -124,7 +130,7 @@ case "$1" in restart ;; try-restart | condrestart) - [ -e $pidfile ] && restart + running && restart ;; resweep) killall -HUP opensm
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Bart,
Quoted 12 lines · Bart Van Assche
Quoted 10 lines · Alex Netes
Review
Quoted 6 lines · Bart Van Assche
(quoted diff) +6
-0+default_rdma_service=openibd +AC_ARG_WITH([rdma_service], + AC_HELP_STRING([--with-rdma-service=name], + [name of the RDMA service: "rdma" when using /etc/init.d/rdma to start RDMA services; "openibd" when using /etc/init.d/openibd to start RDMA services [default=${default_rdma_service}]])) +AC_SUBST(RDMA_SERVICE, ${with_rdma_service:-${default_rdma_service}}) +There is also an option to run opensm with ibsim. In that case neither rdma nor openibd should run.
Quoted 4 lines
Does running opensm with ibsim require to preload libumad2sim ? If so, that's something that's not supported by the current opensm init script, isn't it ? If that is correct then it looks fine to me to make the dependence on the openibd/rdma service explicit in the opensm startup script.
Theoretically, a user can export LD_PRELOAD=libumad2sim.so prior to executing the script. But I agree with you that it can be out of the scope of opensmd script.
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
start () {
+ if [ -e $pidfile ]; thenOn opensm segfault (happens one in a while :), pidfile won't be removed, so you won't be able to start the opensm again. I guess that same thing can happen on warm reboot.
Quoted 5 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ echo Already started + return 1 + fiGood catch. I'll start testing the additional changes below:
Sounds as a good direction.
Quoted 35 lines
scripts/opensm.init.in +8
-3@@ -68,12 +68,18 @@ if [[ -s $CONFIG ]]; then . $CONFIG fi +running () { + test -e $pidfile && + test "$(readlink "/proc/$(cat $pidfile)/exe")" = "@sbindir@/opensm" +} + start () { - if [ -e $pidfile ]; then + if running; then echo Already started return 1 fi echo -n "Starting opensm: " + rm -f $pidfile @sbindir@/opensm --daemon --pidfile $pidfile $OPTIONS > /dev/null if [[ $RETVAL -eq 0 ]]; then success@@ -124,7 +130,7 @@ case "$1" in restart ;; try-restart | condrestart) - [ -e $pidfile ] && restart + running && restart ;; resweep) killall -HUP opensm --
Quoted 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/4 /etc/init.d/opensmd: Improve systemd integration
On recent SLES and openSUSE systems it is necessary to read the file /lib/lsb/init-functions instead of /etc/rc.status for proper integration with systemd. Certain implementations of killproc need a pidfile so make sure that one gets created. Also, correct the opensm service dependency list.
---
v2: replaced "[ -e $pidfile ]" test in start() by "[ -e $pidfile ] && [ "$(readlink "/proc/$(<$pidfile)/exe")" = "@sbindir@/opensm" ]"
configure.in | 6 ++++++ scripts/opensm.init.in | 31 +++++++++++++++++++++++-------- scripts/redhat-opensm.init.in | 2 ++ 3 files changed, 31 insertions(+), 8 deletions(-)
configure.in +6 -0
@@ -11,6 +11,12 @@ AM_INIT_AUTOMAKE AC_SUBST(RELEASE, ${RELEASE:-unknown}) AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz}) +default_rdma_service=openibd +AC_ARG_WITH([rdma_service], + AC_HELP_STRING([--with-rdma-service=name], + [name of the RDMA service: "rdma" when using /etc/init.d/rdma to start RDMA services; "openibd" when using /etc/init.d/openibd to start RDMA services [default=${default_rdma_service}]])) +AC_SUBST(RDMA_SERVICE, ${with_rdma_service:-${default_rdma_service}}) + if { rpm -q sles-release || rpm -q openSUSE-release; } >/dev/null 2>&1; then default_start="2 3 5" default_stop="0 1 4 6"
scripts/opensm.init.in +23 -8
@@ -7,8 +7,8 @@ # ### BEGIN INIT INFO # Provides: opensm -# Required-Start: $syslog -# Required-Stop: +# Required-Start: $syslog @RDMA_SERVICE@ +# Required-Stop: $syslog @RDMA_SERVICE@ # Default-Start: @DEFAULT_START@ # Default-Stop: @DEFAULT_STOP@ # Description: Manage OpenSM
@@ -42,14 +42,22 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +pidfile=/var/run/opensm.pid # Source function library. if [[ -s /etc/init.d/functions ]]; then + # RHEL / CentOS / SL / Fedora. . /etc/init.d/functions rc_status() { :; } rc_exit() { exit $RETVAL; } -fi -if [[ -s /etc/rc.status ]]; then +elif [[ -s /lib/lsb/init-functions ]]; then + # SLES / openSuSE / Debian. + . /lib/lsb/init-functions + rc_exit() { exit $RETVAL; } + success() { log_success_msg; } + failure() { log_failure_msg; } +elif [[ -s /etc/rc.status ]]; then + # Older SuSE systems. . /etc/rc.status failure() { rc_status -v; } success() { rc_status -v; }
@@ -60,11 +68,19 @@ if [[ -s $CONFIG ]]; then . $CONFIG fi +running () { + [ -e $pidfile ] && + [ "$(readlink "/proc/$(<$pidfile)/exe")" = "@sbindir@/opensm" ] +} + start () { + if running; then + echo Already started + return 1 + fi echo -n "Starting opensm: " - @sbindir@/opensm --daemon $OPTIONS > /dev/null + @sbindir@/opensm --daemon --pidfile $pidfile $OPTIONS > /dev/null if [[ $RETVAL -eq 0 ]]; then - touch /var/lock/subsys/opensm success else failure
@@ -76,7 +92,6 @@ stop () { echo -n "Shutting down opensm: " killproc opensm if [[ $RETVAL -eq 0 ]]; then - rm -f /var/lock/subsys/opensm success else failure
@@ -114,7 +129,7 @@ case "$1" in restart ;; try-restart | condrestart) - [ -e /var/lock/subsys/opensm ] && restart + [ -e $pidfile ] && restart ;; resweep) killall -HUP opensm
scripts/redhat-opensm.init.in +2 -0
@@ -7,6 +7,8 @@ # ### BEGIN INIT INFO # Provides: opensm +# Required-Start: $syslog @RDMA_SERVICE@ +# Required-Stop: $syslog @RDMA_SERVICE@ # Default-Start: @DEFAULT_START@ # Default-Stop: @DEFAULT_STOP@ # Description: Manage OpenSM
Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html