diff --git a/etc/init.d.slurm b/etc/init.d.slurm index e7ecce556e8e8b5e142930dfb5388b3ee8d712de..aa467da27f113d33061b3b08fa45de13f2dbbf30 100644 --- a/etc/init.d.slurm +++ b/etc/init.d.slurm @@ -38,15 +38,16 @@ start() { daemon /usr/sbin/$1 $2 RETVAL=$? echo - touch /var/lock/subsys/$prog + touch /var/lock/subsys/slurm return $RETVAL } -stop() { echo -n "stopping $1: " +stop() { + echo -n "stopping $1: " killproc $1 -TERM RETVAL=$? echo - rm -f /var/lock/subsys/$prog + rm -f /var/lock/subsys/slurm return $RETVAL } @@ -57,6 +58,52 @@ startall() { done } +# status() with slight modifications to take into account +# instantiations of job manager slurmd's, which should not be +# counted as "running" +# +slurmstatus() { + local base=${1##*/} + local pid + local rpid + local pidfile + + pidfile=`grep -i ${base}pid /etc/slurm/slurm.conf | grep -v '^ *#'` + if [ $? = 0 ]; then + pidfile=${pidfile##*=} + else + pidfile=/var/run/${base}.pid + fi + + pid=`pidof -o $$ -o $$PPID -o %PPID -x $1 || \ + pidof -o $$ -o $$PPID -o %PPID -x ${base}` + + if [ -f $pidfile ]; then + read rpid < $pidfile + if [ "$rpid" != "" -a "$pid" != "" ]; then + for i in $pid ; do + if [ "$i" = "$rpid" ]; then + echo $"${base} (pid $pid) is running..." + return 0 + fi + done + elif [ "$rpid" != "" -a "$pid" = "" ]; then + echo $"${base} dead but pid file exists" + return 1 + fi + + fi + + if [ "$base" = "slurmctld" -a "$pid" != "" ] ; then + echo $"${base} (pid $pid) is running..." + return 0 + fi + + echo $"${base} is stopped" + + return 3 +} + # # The pathname substitution in daemon command assumes prefix and @@ -81,19 +128,19 @@ case "$1" in ;; status) for prog in `scontrol show daemons`; do - status $prog + slurmstatus $prog done ;; restart) $0 stop && $0 start ;; condrestart) - for prog in `scontrol show daemons`; do - if [ -f /var/lock/subsys/$prog ]; then + if [ -f /var/lock/subsys/slurm ]; then + for prog in `scontrol show daemons`; do stop $prog start $prog - fi - done + done + fi ;; reconfig) for prog in `scontrol show daemons`; do diff --git a/slurm.spec.in b/slurm.spec.in index 6df2de3bec7b418d0016573c7ee39322ea058c25..e65d34cb541e633e91912a8bdf04af64398fdff4 100644 --- a/slurm.spec.in +++ b/slurm.spec.in @@ -174,9 +174,10 @@ fi if [ -x /etc/rc.d/init.d/slurm ]; then [ -x /sbin/chkconfig ] && /sbin/chkconfig --del slurm [ -x /sbin/chkconfig ] && /sbin/chkconfig --add slurm - if ! /etc/rc.d/init.d/slurm status | grep -q running; then + if ! /etc/rc.d/init.d/slurm status | grep -q running \ + || ! /etc/rc.d/init.d/slurm test | grep -q slurmctld; then /etc/rc.d/init.d/slurm start - fi + fi fi %preun