Update FreeBSD service script

This commit is contained in:
JonnyWong16 2016-09-18 21:58:44 -07:00
parent 82499a53d4
commit 51c9aa2887
2 changed files with 17 additions and 7 deletions

View file

@ -49,23 +49,33 @@ fi
verify_plexpy_pid() { verify_plexpy_pid() {
# Make sure the pid corresponds to the PlexPy process. # Make sure the pid corresponds to the PlexPy process.
if [ -f ${plexpy_pid} ]; then
pid=`cat ${plexpy_pid} 2>/dev/null` pid=`cat ${plexpy_pid} 2>/dev/null`
ps -p ${pid} | grep -q "python ${plexpy_dir}/PlexPy.py" ps -p ${pid} | grep -q "python2 ${plexpy_dir}/PlexPy.py"
return $? return $?
else
return 0
fi
} }
# Try to stop PlexPy cleanly by calling shutdown over http. # Try to stop PlexPy cleanly by sending SIGTERM
plexpy_stop() { plexpy_stop() {
echo "Stopping $name" echo "Stopping $name"
verify_plexpy_pid verify_plexpy_pid
if [ -n "${pid}" ]; then if [ -n "${pid}" ]; then
kill ${pid}
wait_for_pids ${pid} wait_for_pids ${pid}
echo "Stopped" echo "Stopped."
fi fi
} }
plexpy_status() { plexpy_status() {
verify_plexpy_pid && echo "$name is running as ${pid}" || echo "$name is not running" verify_plexpy_pid
if [ -n "${pid}" ]; then
echo "$name is running as ${pid}."
else
echo "$name is not running."
fi
} }
run_rc_command "$1" run_rc_command "$1"

View file

@ -58,7 +58,7 @@ verify_plexpy_pid() {
fi fi
} }
# Try to stop PlexPy cleanly by calling shutdown over http. # Try to stop PlexPy cleanly by sending SIGTERM
plexpy_stop() { plexpy_stop() {
echo "Stopping $name." echo "Stopping $name."
verify_plexpy_pid verify_plexpy_pid