-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.d_gpu_killer
executable file
·57 lines (50 loc) · 1.49 KB
/
init.d_gpu_killer
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
#!/bin/bash
### BEGIN INIT INFO
# Provides: gpu_killer
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short Description: Kill processes which access GPU without reservation on SGE
# Description: gpu_killer
### END INIT INFO
# Script written by Vijayaditya Peddinti, adapted from a similar script written
# by Dan Povey called "mem_killer"
# /etc/init.d/gpu_killer
OPTS="--query-interval 2 --notify-email clsphelp@clsp.jhu.edu"
. /lib/lsb/init-functions
# it is important to name the exe gpu_killer.py and not gpu_killer
# as doing `basename $DAEMON` would give us gpu_killer which
# when used with killall could kill the init.d script before
# the $DAEMON process. Using $DAEMON in place of `basename $DAEMON`
# is not an option as the process gets the name gpu_killer and
# not /sbin/gpu_killer
DAEMON=/sbin/gpu_killer.py
case "$1" in
start)
echo "Starting $DAEMON"
# Silently kill any old process.
killall -u root `basename $DAEMON` >&/dev/null
nohup $DAEMON $OPTS </dev/null >&/dev/null &
;;
stop)
echo "Stopping $DAEMON"
killall -u root `basename $DAEMON`
;;
restart)
echo "Stopping $DAEMON"
killall -u root `basename $DAEMON`
echo "Starting $DAEMON"
nohup $DAEMON $OPTS </dev/null >&/dev/null &
;;
status)
status_of_proc $DAEMON `basename $DAEMON` && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/gpu_killer {start|stop|restart|status}"
exit 1
;;
esac
exit 0