Stop plex service with the s6 supervisor (#53)

S6 will now send SIGTERM to the root Plex process as a part of the service's finish script.  If the processes don't exit after 5 seconds, all processes are sent a SIGKILL
This commit is contained in:
Nate 2020-05-28 07:59:48 -05:00 committed by GitHub
parent f4e62e8dd4
commit b8f67a0b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#!/usr/bin/with-contenv bash
# Copied from the init.d stop method from non-Dockerized Plex.
echo "Stopping Plex Media Server."
# Ask nicely
pids="$(ps -ef | grep 'Plex Media Server' | grep -v grep | awk '{print $2}')"
kill -15 $pids
sleep 5
# Stuck
pids="$(ps -ef | grep /usr/lib/plexmediaserver | grep -v grep | awk '{print $2}')"
if [ "$pids" != "" ]; then
kill -9 $pids
sleep 2
fi

View File

@ -0,0 +1 @@
8000

7
root/plex_service.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
if [ "$#" -eq 1 ]; then
s6-svc "$1" /var/run/s6/services/plex
else
echo "No argument supplied; must be -u, -d, or -r."
fi