-
Notifications
You must be signed in to change notification settings - Fork 80
/
slurmdbd.init
174 lines (155 loc) · 4.03 KB
/
slurmdbd.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/sh
#
# chkconfig: 345 90 10
# description: SLURMDBD is a database server interface for \
# SLURM (Simple Linux Utility for Resource Management).
#
# processname: /usr/sbin/slurmdbd
# pidfile: /var/run/slurm/slurmdbd.pid
#
# config: /etc/sysconfig/slurm
#
### BEGIN INIT INFO
# Provides: slurm-slurmdbd
# Required-Start: $remote_fs $syslog $network munge
# Required-Stop: $remote_fs $syslog $network munge
# Should-Start: $named mysql
# Should-Stop: $named mysql
# 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
SBINDIR=/usr/sbin
LIBDIR=/usr/lib
CONFFILE="/etc/slurm/slurmdbd.conf"
DESCRIPTION="slurm database server interface"
NAME="slurmdbd"
# Source slurm specific configuration
if [ -f /etc/default/slurm ] ; then
. /etc/default/slurm
else
SLURMDBD_OPTIONS=""
fi
#Checking for configuration file
if [ ! -f $CONFFILE ] ; then
if [ -n "$(echo $1 | grep start)" ] ; then
echo Not starting slurmdbd
fi
echo $CONFFILE not found
exit 0
fi
#Checking for lsb init function
if [ -f /lib/lsb/init-functions ] ; then
. /lib/lsb/init-functions
else
echo Can\'t find lsb init functions
exit 1
fi
getpidfile() {
dpidfile=`grep PidFile $CONFFILE | grep -v '^ *#'`
if [ $? = 0 ]; then
dpidfile=${dpidfile##*=}
dpidfile=${dpidfile%#*}
else
dpidfile=/var/run/slurm/slurmdbd.pid
fi
echo $dpidfile
}
# setup library paths for slurm and munge support
export LD_LIBRARY_PATH=$LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
start() {
# Create run-time variable data
mkdir -p /var/run/slurm
chown slurm:slurm /var/run/slurm
unset HOME MAIL USER USERNAME
log_daemon_msg "Starting $DESCRIPTION"
STARTERRORMSG="$(start-stop-daemon --start --oknodo \
--exec "$SBINDIR/$NAME" -- $SLURMDBD_OPTIONS 2>&1)"
STATUS=$?
if [ "$STARTERRORMSG" != "" ] ; then
STARTERRORMSG=$(echo $STARTERRORMSG | sed "s/.$//")
log_progress_msg $STARTERRORMSG
else
log_progress_msg $NAME
fi
touch /var/lock/$NAME
log_end_msg $STATUS
}
stop() {
log_daemon_msg "Stopping $DESCRIPTION"
STOPERRORMSG="$(start-stop-daemon --oknodo --stop -s TERM \
--exec "$SBINDIR/$NAME" 2>&1)"
STATUS=$?
if [ "$STOPERRORMSG" != "" ] ; then
STOPERRORMSG=$(echo $STOPERRORMSG | sed "s/.$//")
log_progress_msg $STOPERRORMSG
else
log_progress_msg "$NAME"
fi
log_end_msg $STATUS
rm -f /var/lock/$NAME
}
slurmstatus() {
base=${1##*/}
pidfile=$(getpidfile)
pid=`pidof -o $$ -o $$PPID -o %PPID -x slurmdbd`
if [ -f $pidfile ]; then
read rpid < $pidfile
if [ "$rpid" != "" -a "$pid" != "" ]; then
for i in $pid ; do
if [ "$i" = "$rpid" ]; then
echo "slurmdbd (pid $pid) is running..."
return 0
fi
done
elif [ "$rpid" != "" -a "$pid" = "" ]; then
echo "slurmdbd is stopped"
return 1
fi
fi
echo "slurmdbd is stopped"
return 3
}
#
# 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
;;
stop)
stop
;;
status)
slurmstatus
;;
restart)
stop
sleep 1
start
;;
force-reload)
$0 stop
$0 start
;;
condrestart)
if [ -f /var/lock/subsys/slurm ]; then
stop
start
fi
;;
reconfig)
PIDFILE=$(getpidfile)
start-stop-daemon --stop --signal HUP --pidfile \
"$PIDFILE" --quiet slurmdbd
;;
*)
echo "Usage: $0 {start|stop|status|restart|condrestart|reconfig}"
exit 1
;;
esac