Last active
March 31, 2017 16:55
-
-
Save linuxluser/fe14eef12e548029af5684cb5adebf51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: nvidia-docker | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: A Docker plugin that brings Nvidia support to containers | |
# Description: A Docker plugin that brings Nvidia support to containers | |
### END INIT INFO | |
LOGFILE=/var/log/nvidia-docker.log | |
ERRORFILE=/var/log/nvidia-docker.err | |
PIDFILE=/var/run/nvidia-docker.pid | |
start() { | |
local pid | |
/usr/bin/nvidia-docker-plugin >>$LOGFILE 2>>$ERRORFILE | |
pid=$(pidof -s nvidia-docker-plugin || true) | |
if [ -z "$pid" ]; then | |
echo "Failed to start - check $ERRORFILE for details" >&2 | |
exit 1 | |
fi | |
echo $pid >$PIDFILE | |
} | |
stop() { | |
local force | |
force=$1 | |
PID=$(cat $PIDFILE) | |
if [ -z "PID" ]; then | |
return | |
fi | |
if [ $force ]; then | |
kill -9 $PID | |
else | |
kill $PID | |
fi | |
rm -f $PIDFILE | |
} | |
status() { | |
local pid | |
pid=$(pidof -s nvidia-docker-plugin || true) | |
if [ -n "$pid" ]; then | |
echo "Running as process $pid" | |
else | |
echo "Not running" | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
force-reload) | |
stop true | |
start | |
;; | |
status) | |
status | |
;; | |
*) | |
echo "Usage: service nvidia-docker {start|stop|restart|status}" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment