From 7cfd029b31cd01bd0cc66ee02732e530ca137eba Mon Sep 17 00:00:00 2001 From: Chris Hines <chris.hines@monash.edu> Date: Fri, 20 Mar 2015 01:40:54 +0000 Subject: [PATCH] an init scripts for the slurmdbd on debian (apparently slurm devs only produce init scripts for redhat) --- roles/slurmdb/templates/slurmdbd.initd.j2 | 223 ++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 roles/slurmdb/templates/slurmdbd.initd.j2 diff --git a/roles/slurmdb/templates/slurmdbd.initd.j2 b/roles/slurmdb/templates/slurmdbd.initd.j2 new file mode 100644 index 00000000..afeb6cab --- /dev/null +++ b/roles/slurmdb/templates/slurmdbd.initd.j2 @@ -0,0 +1,223 @@ +#!/bin/bash +# +# chkconfig: 345 90 10 +# description: SLURMDBD is a database server interface for \ +# SLURM (Simple Linux Utility for Resource Management). +# +# processname: ${exec_prefix}/sbin/slurmdbd +# pidfile: /var/run/slurmdbd.pid +# +# config: /etc/sysconfig/slurm +# +### BEGIN INIT INFO +# Provides: slurmbd +# Required-Start: $remote_fs $syslog $network munge +# Required-Stop: $remote_fs $syslog $network munge +# Should-Start: $named +# Should-Stop: $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: SLURM database daemon +# Description: Start slurm to provide database server for SLURM +### END INIT INFO + +exec_prefix="{{ slurm_dir }}" +prefix="{{ slurm_dir }}" +CONFDIR="${prefix}/etc" +LIBDIR="${exec_prefix}/lib" +SBINDIR="${exec_prefix}/sbin" + +#Source function library. +if [ -f /etc/rc.status ]; then + . /etc/rc.status + SUSE=1 + STARTPROC=startproc + + rc_reset +else + # Read configuration defaults to override variables: + # $CONFIG, $DAEMON_ARGS, $PIDFILE, $USER, $NICE, $SIGHUP_RELOAD + ## + for dir in "$sysconfdir/default" "$sysconfdir/sysconfig"; do + [ -r "$dir/$INIT_NAME" ] && . "$dir/$INIT_NAME" + done + [ -z "$DAEMON_ARGS" -a -n "$OPTIONS" ] && DAEMON_ARGS="$OPTIONS" + [ "`id | sed 's/^uid=\([0-9]*\).*/\1/'`" -ne 0 ] && unset USER + expr -- "$NICE" : '[0-9]*$' >/dev/null 2>&1 && NICE="+$NICE" + [ -n "$SIGHUP_RELOAD" -a "$SIGHUP_RELOAD" != 0 ] \ + && RELOAD=1 || unset RELOAD + + if [ -f /etc/debian_version -a -x /sbin/start-stop-daemon ]; then + SYSTEM="DEBIAN" + [ -r /etc/default/rcS ] && . /etc/default/rcS + [ -r /lib/init/vars.sh ] && . /lib/init/vars.sh + [ -r /lib/lsb/init-functions ] && . /lib/lsb/init-functions + STARTPROC="start_daemon" + elif [ -f /etc/redhat-release -a -r /etc/rc.d/init.d/functions ]; then + SYSTEM="REDHAT" + . /etc/rc.d/init.d/functions + RH_LOCK="/var/lock/subsys/$INIT_NAME" + SUSE=0 + STARTPROC=daemon + elif [ -f /etc/SuSE-release -a -r /etc/rc.status ]; then + SYSTEM="SUSE" + . /etc/rc.status + rc_reset + elif [ -r /lib/lsb/init-functions ]; then + SYSTEM="LSB" + . /lib/lsb/init-functions + else + SYSTEM="OTHER" + fi + + + function rc_status() { + RETVAL=$? + } + function rc_exit () { + exit $RETVAL + } + RETVAL=0 +fi + +# We can not use a starter program without losing environment +# variables that are critical on Blue Gene systems +if [ -d /bgl/BlueLight/ppcfloor ]; then + STARTPROC="" +fi + +# Source slurm specific configuration +# SLURMDBD_OPTIONS defines slurmdbd command line options. See "man slurmdbd" +if [ -f /etc/sysconfig/slurm ] ; then + . /etc/sysconfig/slurm +else + SLURMDBD_OPTIONS="" +fi + +if [ ! -f $CONFDIR/slurmdbd.conf ]; then + echo "Could not find $CONFDIR/slurmdbd.conf. Bad path?" + exit 1 +fi + +# setup library paths for slurm and munge support +export LD_LIBRARY_PATH=$LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} + +start() { + prog=$1 + shift + echo -n "starting $prog: " + unset HOME MAIL USER USERNAME + $STARTPROC $SBINDIR/$prog $SLURMDBD_OPTIONS + rc_status -v + echo + touch /var/lock/subsys/slurmdbd +} + +stop() { + echo -n "stopping $1: " + killproc $1 -TERM + rc_status -v + echo + rm -f /var/lock/subsys/slurmdbd +} + +slurmstatus() { + local base=${1##*/} + local pid + local rpid + local pidfile + + pidfile=`grep -i pidfile $CONFDIR/slurmdbd.conf | grep -v '^ *#'` + if [ $? = 0 ]; then + pidfile=${pidfile##*=} + pidfile=${pidfile%#*} + pidfile=${pidfile//\"/} + else + pidfile=/var/run/slurmdbd.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" = "slurmdbd" -a "$pid" != "" ] ; then + echo $"${base} (pid $pid) is running..." + return 0 + fi + + echo $"${base} is stopped" + + return 3 +} + +# +# stop slurm daemons, +# wait for termination to complete (up to 10 seconds) before returning +# +slurmstop() { + stop $1 + + for i in 1 2 3 4 + do + sleep $i + slurmstatus $1 + if [ $? != 0 ]; then + break + fi + done +} +# +# The pathname substitution in daemon command assumes prefix and +# exec_prefix are same. This is the default, unless the user requests +# otherwise. +# +# Any node can be a slurm controller and/or server. +# +case "$1" in + start) + start slurmdbd + ;; + stop) + slurmstop slurmdbd + ;; + status) + slurmstatus slurmdbd + rc_status -v + ;; + restart) + $0 stop + $0 start + ;; + condrestart) + if [ -f /var/lock/subsys/slurm ]; then + stop slurmdbd + start slurmdbd + fi + ;; + reconfig|reload) + echo -n $"Reloading slurmdbd daemon configuration: " + killproc slurmdbd -HUP + echo + ;; + *) + echo "Usage: $0 {start|stop|status|restart|condrestart|reconfig}" + exit 1 + ;; +esac + +rc_exit -- GitLab