-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stopping Plex Service does not stop all Plex Media Server processes #29
Comments
Hi, I've experience the same issue, I'm running WIndows Server 2016 Core. Here is a Powershell session that shows the problem: C:\Users\PlexService\Documents> [System.Environment]::OSVersion.Version Major Minor Build Revision 10 0 16299 0 C:\Users\PlexService\Documents> Get-Service Plex* Status Name DisplayName Stopped PlexService PlexService C:\Users\PlexService\Documents> Get-Process Plex* Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
C:\Users\PlexService\Documents> Get-Service Plex* Status Name DisplayName Running PlexService PlexService C:\Users\PlexService\Documents> Stop-Service PlexService Status Name DisplayName Stopped PlexService PlexService C:\Users\PlexService\Documents> Get-Process Plex* Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
C:\Users\PlexService\Documents> get-content "C:\Users\PlexService\AppData\Local\Plex Service\plexServiceLog.txt" |
Should be resolved in release 1.1.5. Please test and I'll close this issue. Thanks. |
@cjmurph I've just upgraded to version 1.1.5 and can confirm that it solved the issue on my machine:-) Thanks for the quick response, and for this great software! |
Great, thanks! |
Thanks for that. I've just upgraded to 1.1.5 but it doesn't fix it for me (unfortunately). Stopping the Plex Service from the Windows Service Control Manager (e.g. Computer Management's services snap-in) leaves four processes (2 x conhost.exe, 2 x PlexScriptHost.exe). One thought I had is this: my Plex Media Server service account is an ordinary user (not an administrator) with the user rights to log on as a service and file system permissions to access the service account AppData folder. Ordinary users do have the right to kill their own processes, so perhaps this isn't related. @cjmurph Is there any more information you'd like me to collect? Thanks. |
Interesting. It doesn't try and kill conhost, but it should get all the plexscripthost instances, unless they are spawning after. I tested it many times on my PC and it got them all every time. Is conhost a Plex process or a windows process spawned by a Plex process? |
Also, I do have the shutdown call continue after 10 seconds if the stop call hasn't come back as complete. Maybe I can blow that out a bit and see if it's just taking longer on your machine. 10 seconds is a long time though when all your'e doing is killing processes |
conhost.exe is a window process that's a child of PlexScriptHost.exe (must be a supporting function for console-based executables - probably not spawned explicitly by it but attached automatically by Windows). If PlexScriptHost.exe is killed, it exits (so no need to kill it). Here's the before after / process trees (note that PlexService.exe and "Plex Media Server.exe", the parent processes of the two remaining ones, have gone, leaving them orphaned). Killing PlexScriptHost.exe manually (using Task Manager) is instant, so I don't think there'd be a delay. How are you finding the processes to kill? Processes matching names running as the same user as the Plex Service (or that configured in the Plex Service Windows service configuration)? I can run some PowerShell to match your logic and see what it says, if you like. |
Here's a snippet from the log for the shutdown. Registry Export won't be running - it's a task at start up to run Reg.exe to export the Plex Media Server registry keys for backup purposes. So that all finishes within a second or so.
|
That actually looks like a log from 1.1.4. It doesn't wait at all. Can you try uninstalling and reinstalling rather than upgrading? |
I finally got round to uninstalling / reinstalling and trying again, and I then finally got round to writing here. Sorry it took so long. When I uninstalled, I made sure that all config files, etc. where removed before installing again. Attached is a log that me stopping / starting Plex from the Plex Service menu and also restart Plex Service from Windows. But looks the same in the log, I think. Practically, I noticed that:
Thanks. |
Hi, The service doesn't keep tabs on the supporting processes, other than, when plex stops, it has a list of process names to hunt down and kill. So, there really shouldn't be any "orphaned" processes left behind, unless the shutdown procedure is cut short for some reason. I absolutely cannot replicate what you're showing for a restart case. On the three test machines I have, it behaves exactly as expected, with one caveat... Plex update service will always come back as it is actually a windows service itself and I shouldn't even be attempting to kill it. I'll remove it from the list for the next release. I would llike to ensure this does in fact work correctly, however I must ask why you would even restart the service? The service itself should always remain running, and plex should be started and stopped from the tray icon (which doesn't start and stop the service, just plex). Thanks! |
Interestingly, your logs don't show plex attempting to kill any of the supporting processes, It only kills plex and what looks like an auxilliary application called "Registry Export". Are you on the latest version? |
Hi. Taking your questions one-by-one... "from the windows service console" - Yes. For example, services.msc "unless the shutdown procedure is cut short for some reason" - I think Windows waits for at least 30 seconds before timing out a Windows service shutdown / restart (timing out to the application doing the restart like services.mcs, but probably carries on the shutdown or shutdown part of the restart anyway in the background). In this case, the Plex Service restarts quite quickly, suggesting it quits quickly too (either gracefully or otherwise). "Plex update service will always come back" - I've got that service disabled (and a scheduled task to keep it that way) "why you would even restart the service?" - The use case for I have is a scheduled task that runs daily to backup (using Robocopy mirror) data to a different computer. For certain sets of data that it copies, it needs to shut down the service that uses the data, otherwise files are in use and can't be copied (or potentially inconsistent). The same orphaned processes apply with Plex Service is shutdown from services.msc, which is what the backup Windows PowerShell script does. I could manually kill the orphaned processes in the script (after issuing a Plex Service shutdown), but the scheduled task that runs the backup script runs as an ordinary user (for security via least privilege) but with permission previously granted to control the Plex Service (done via SC.exe). "auxilliary application called "Registry Export"" - That's a command I run to export the Plex registry settings using "Reg.exe Export" to allow for recovery of the Plex database from backup. I've verified that Reg.exe runs, does it's job then quits at Plex startup, so there's nothing to kill. "Are you on the latest version?" - This is with 1.1.5 (previously it was on the same version but it was an upgrade and you said the logs looked like it hadn't upgraded properly: hence the clean installation). Thanks. |
Great info, thank you :) ok, my primary concern is that the logs don't show any attempt at all to kill those processes. When the service is called to stop, it issues the stop command and awaits the state to change to stopped, which only happens after cleaning up all the extra processes and auxiliary applications. It doesn't take very long and the wait will timeout after 10 seconds (if it takes that long there is a problem anyway). I'll add some more in depth logging to the service logs around this procedure and get you to try with that. I'll hopefully get to that tonight or tomorrow. |
I've added more verbose logging in release 1.1.7. you should get a log file that looks like the following when stopping plex: 7/05/2018 9:12:35 PM: Killing Plex. |
Hi. Thanks for that - upgraded. Before test: Stop Plex via Plex Service. Stop Plex Service. Check that no processes are running as the Plex service account user 19:43 - Start Plex Service. Processing running after: 3 x connhost.exe, 1 x Plex Media Server.exe, 2 x PlexScriptHost.exe, 1 x Plex Tuner Service.exe Weird. If you look at the log, the last Plex Service stop at 19:52 didn't have the log entries for the process clean up ("Plex Media Server has stopped!" to "Plex Service Stopped"). This is the test where the PMS processes were left running. The same action at 19:47 does have the actions and the processes were killed |
It's definitely terminating early. I wonder if it's actually crashing during stop. Can you have a look at the windows event viewer at those times? I'm away for work at the moment, but I'll see if I can get a VM up and running to test. |
Nothing in the Application or System logs to indicate a user-mode crash. No rush to do anything at all: as and when you can. The only thing I can see is event ID 10016 in the System log a couple of minutes after PMS starts: The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
|
it's been 5 years, I don't think this is still a thing. |
Stopping Plex Service via Windows service control manager (e.g. Services MMC snapp-in) does not stop all process started by Plex Service / the Plex Media Server service account used by Plex Service
Step to reproduce:
Thanks for the great software. Hopefully you can reproduce this but do let me know if you need any more information. Thanks.
The text was updated successfully, but these errors were encountered: