Box: 12.0-STABLE FreeBSD 12.0-STABLE r343863 GENERIC amd64 Port: multimedia/plexmediaserver-plexpass version 1.15.1.707_1 Each time I stop the service "plexmediaserver_plexpass" for a reboot or manually, I get this issue: stop process hangs at this step: Cleaning up leftover child processes. Waiting for PIDS: XXXX Example if I stop the service manually: $ sudo service plexmediaserver_plexpass stop Stopping plexmediaserver_plexpass. Waiting for PIDS: 2942, 2942. Cleaning up leftover child processes. Waiting for PIDS: 2950 2948 2943 So I searched info about this PID 2943 $ ps -aux | grep 2943 plex 2943 0.0 0.7 127360 58340 - IN 11:52 0:08.80 Plex Plug-in [com.plexapp.system] /usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap root 2984 0.0 0.0 10664 2156 5 I+ 11:53 0:00.00 pwait 2950 2948 2943 alexandre 2995 0.0 0.0 11504 2796 7 S+ 11:53 0:00.00 grep 2943 In the log /usr/local/plexdata-plexpass/Plex Media Server/Logs/PMS Plugin Logs/com.plexapp.system.log I get this during the stop of the process 2019-02-28 11:54:07,449 (806ed8d00) : DEBUG (runtime:1156) - Starting timed thread named 'refresh_servers' │ │2019-02-28 11:54:07,450 (806ed8d00) : DEBUG (peerservice:164) - Fetching the current list of servers │ │2019-02-28 11:54:07,451 (806ed8d00) : DEBUG (networking:166) - Requesting 'http://127.0.0.1:32400/servers' │ │2019-02-28 11:54:07,457 (806ed8d00) : CRITICAL (runtime:1128) - Exception in thread named 'refresh_servers' (most recent call last): │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 1126, in _start_thread │ │ f(*args, **kwargs) │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/System.bundle/Contents/Code/peerservice.py", line 169, in refresh_servers │ │ servers_el = self.get_servers_el() │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/System.bundle/Contents/Code/peerservice.py", line 165, in get_servers_el │ │ return XML.ElementFromURL('http://127.0.0.1:32400/servers', cacheTime = 0) │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/parsekit.py", line 344, in ElementFromURL │ │ method=method, │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/networkkit.py", line 67, in _http_request │ │ req = self._core.networking.http_request(url, *args, **kwargs) │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 370, in http_request │ │ return HTTPRequest(self._core, url, data, h, url_cache, encoding, errors, timeout, immediate, sleep, opener, follow_redirects, method) │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 141, in __init__ │ │ self.load() │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 181, in load │ │ f = self._opener.open(req, timeout=self._timeout) │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 438, in open │ │ response = self._open(req, data) │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 456, in _open │ │ '_open', req) │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 416, in _call_chain │ │ result = func(*args) │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 1217, in http_open │ │ return self.do_open(httplib.HTTPConnection, req) │ │ File "/usr/local/share/plexmediaserver-plexpass/Resources/Plug-ins-d893009fb/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 1192, in do_open │ │ raise URLError(err) │ │URLError: <urlopen error [Errno 61] Connection refused>
I have never been able to reproduce this. Plex always stops cleanly, including all of the child processes.
This issue is really strange, because I didn't modified the port or any file of this port. I found this thread on Plex forums https://forums.plex.tv/t/plex-tuner-service-is-not-stopping-preventing-shut-down-of-plex-service/197913/23 To solve this problem, Mikec_pt gave the solution: I tested it with success. ----- 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 /usr/local/etc/rc.d/plexmediaserver_plexpass file: kill $sig_stop ${_PLEX_CHILDREN} TO kill -9 ${_PLEX_CHILDREN} -----
A commit references this bug: Author: feld Date: Mon Mar 25 14:44:55 UTC 2019 New revision: 496825 URL: https://svnweb.freebsd.org/changeset/ports/496825 Log: multimedia/plexmediaserver{-plexpass}: Improve service shutdown reliability Plex child worker processes don't handle TERM PR: 236104 Changes: head/multimedia/plexmediaserver/Makefile head/multimedia/plexmediaserver/files/plexmediaserver.in head/multimedia/plexmediaserver-plexpass/Makefile head/multimedia/plexmediaserver-plexpass/files/plexmediaserver_plexpass.in
We'll kill the child processes with -9 now