Plex Tuner Service is not stopping, preventing shut down of Plex service

I modified the script /usr/local/etc/rc.d/plexmediaserver_plexpass with the suggestions [1], but it didn’t resolve the issue.

$ ps aux | grep -i plex
plex      14688   0.0  1.4  242112 116796  -  Is   15:32        0:01.84 /usr/local/share/plexmediaserver-plexpass/Plex_Media_Server (Plex Media Server)
plex      15186   0.0  0.7  127336  58024  -  IN   15:32        0:08.73 Plex Plug-in [com.plexapp.system] /usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-8bec0f76c/Framework.bundle/Contents/Resources/Versions/2/Python/boots
plex      19483   0.0  0.3   43016  21572  -  I    15:32        0:00.09 /usr/local/share/plexmediaserver-plexpass/Plex Tuner Service /usr/local/share/plexmediaserver-plexpass/Resources/Tuner/Private /usr/local/share/plexmediaserver-plex
plex      20128   0.0  0.6   84876  48792  -  I    15:32        0:06.13 Plex Plug-in [com.plexapp.agents.imdb] /usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-8bec0f76c/Framework.bundle/Contents/Resources/Versions/2/Python/

When I stop plexmediaserver_plexpass, the plugins “Plex Plug-in [com.plexapp.agents.imdb]” and “Plex Plug-in [com.plexapp.system]” hang despite the modified service stop command [1].

$ sudo /usr/local/etc/rc.d/plexmediaserver_plexpass stop
Stopping plexmediaserver_plexpass.
Waiting for PIDS: 14688, 14688.
Force killing 'Plex Tuner Service'
Waiting for PIDS: 19483.
Cleaning up leftover child processes.
Waiting for PIDS: 20128 15186

[1]

plex_stop_postcmd()
{
        echo "Force killing 'Plex Tuner Service'"
        _TUNER_SERVICE=$(pgrep -f "Plex Tuner Service" -g ${_PLEXID})
        kill -9 ${_TUNER_SERVICE}
        wait_for_pids ${_TUNER_SERVICE}


        echo "Cleaning up leftover child processes."
        _PLEX_CHILDREN=$(pgrep -g ${_PLEXPID})
        kill $sig_stop ${_PLEX_CHILDREN}
        wait_for_pids ${_PLEX_CHILDREN}
}

So I was actually spending some time on this today.

The truth is we don’t actually handle SIGTERM on any of the chidlren for freebsd or linux (or anything that’s not windows really)

This is because it should be safe to do a SIGKILL.

That said the port should update the script to send -9 rather then TERM when stopping children.
This is what the linux scripts do anyway.

Until the port updates please update:
kill $sig_stop ${_PLEX_CHILDREN}
TO
kill -9 ${_PLEX_CHILDREN}

3 Likes

Thank you very much for spending time on this issue.
I confirm it works like a charm <3

Awesome, works great! Glad to hear it’s coming soon to ports, thanks for a little FreeBSD love