From 584fd444b095e6b4bb84e90118b79197bc458d3c Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 29 Mar 2007 19:05:54 +0000
Subject: [PATCH] svn merge -r11263:11266
 https://eris.llnl.gov/svn/slurm/branches/slurm-1.1

---
 NEWS             |  2 ++
 etc/init.d.slurm | 31 ++++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 63d8e430a9a..2b6ad4ab8d8 100644
--- a/NEWS
+++ b/NEWS
@@ -264,6 +264,8 @@ documents those changes that are of interest to users and admins.
 =========================
  - Insure that slurm_signal_job_step() is defined in srun for mvapich
    and mpichgm error conditions.
+ - Modify /etc/init.d/slurm restart command to wait for daemon to terminate
+   before starting a new one
  - Permit job steps to be started on draining nodes that have already 
    been allocated to that job.
 
diff --git a/etc/init.d.slurm b/etc/init.d.slurm
index 045a38e9094..7e807576e34 100644
--- a/etc/init.d.slurm
+++ b/etc/init.d.slurm
@@ -93,6 +93,7 @@ startall() {
     done
 }
 
+#
 # status() with slight modifications to take into account
 # instantiations of job manager slurmd's, which should not be
 # counted as "running"
@@ -124,7 +125,11 @@ slurmstatus() {
                 fi     
             done
         elif [ "$rpid" != "" -a "$pid" = "" ]; then
-            echo $"${base} dead but pid file exists"
+#           Due to change in user id, pid file may persist 
+#           after slurmctld terminates
+            if [ "$base" != "slurmctld" ] ; then
+               echo $"${base} dead but pid file exists"
+            fi
             return 1
         fi 
 
@@ -140,6 +145,27 @@ slurmstatus() {
     return 3
 }
 
+#
+# stop slurm daemons, 
+# wait for termination to complete (up to 10 seconds), then restart
+#
+slurmrestart() {
+    for prog in `$BINDIR/scontrol show daemons`; do
+       stop $prog
+
+       for i in 1 2 3 4
+       do
+          sleep $i
+          slurmstatus $prog
+          if [ $? != 0 ]; then
+             break
+          fi
+       done
+
+       optvar=`echo ${prog}_OPTIONS | tr "a-z" "A-Z"`
+       start $prog ${!optvar}
+    done
+}
 
 #
 # The pathname substitution in daemon command assumes prefix and
@@ -168,8 +194,7 @@ case "$1" in
 	done
         ;;
     restart)
-        $0 stop
-	$0 start
+        slurmrestart
         ;;
     condrestart)
         if [ -f /var/lock/subsys/slurm ]; then
-- 
GitLab