cjmurph / PmsService

Plex Media Server service wrapper for windows
MIT License
504 stars 57 forks source link

PlexService won't automatically start on server reboot, but manually starts fine #74

Closed AnthonyBe closed 1 year ago

AnthonyBe commented 1 year ago

I've been running into this slightly annoying issue ever since I updated from v1.1.7 to v1.2.0 and it persists with v1.2.1 I'm running Plex x64 on a Windows Server 2012 R2 server.

When I reboot the server, the PlexService never starts automatically. After I log in, I can manually start it without any problem. It will then work perfectly, handle PMS updates, etc. just fine. It just won't auto-start on server reboot. There are no errors which makes it even harder for me to troubleshoot.

The PlexService service is set to Automatic startup The PlexService service is configured to run under the local Administrator account (I know, bad practice.. but it works..)

After I reboot the server, this is what I see in the System Event Log:

Error   16/02/2023 1:36:59 PM   Service Control Manager 7000    None
The PlexService service failed to start due to the following error: 
The service did not respond to the start or control request in a timely fashion.
Error   16/02/2023 1:36:59 PM   Service Control Manager 7009    None
A timeout was reached (30000 milliseconds) while waiting for the PlexService service to connect.

As mentioned, when I manually start the service, it is happy and logs the following:

System Log
Information 16/02/2023 1:56:20 PM   Service Control Manager 7036    None
The PlexService service entered the running state.
Application Log
Information 16/02/2023 1:56:20 PM   PlexMediaServerService  0   None
Service started successfully.

This is a sample of the PlexService.log on a day when I rebooted the server, note that 13:36 is when the service failed to start automatically, and 13:56 is when it was successfully manually started. At 13:36, nothing is logged.

[13:19:44 INF][PmsMonitor][EndPlex] Killing Plex.
[13:19:44 INF][PmsMonitor][Plex_Exited] Plex Media Server has stopped!
[13:19:44 INF][PmsMonitor][Plex_Exited] Wait some time for the update log to be written before reacting to this exit event
[13:19:54 INF][PmsMonitor][KillSupportingProcesses] Killing supporting processes.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: Plex DLNA Server
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 0 instances of Plex DLNA Server found.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: PlexScriptHost
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 9 instances of PlexScriptHost found.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Stopping PlexScriptHost with PID of 8076.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] PlexScriptHost with PID stopped
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Stopping PlexScriptHost with PID of 2744.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] PlexScriptHost with PID stopped
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Stopping PlexScriptHost with PID of 1324.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] PlexScriptHost with PID stopped
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Stopping PlexScriptHost with PID of 4104.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] PlexScriptHost with PID stopped
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Stopping PlexScriptHost with PID of 6604.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] PlexScriptHost with PID stopped
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Stopping PlexScriptHost with PID of 4732.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] PlexScriptHost with PID stopped
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Stopping PlexScriptHost with PID of 6576.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] PlexScriptHost with PID stopped
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Stopping PlexScriptHost with PID of 7740.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] PlexScriptHost with PID stopped
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Stopping PlexScriptHost with PID of 6184.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] PlexScriptHost with PID stopped
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: PlexTranscoder
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 0 instances of PlexTranscoder found.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: PlexNewTranscoder
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 0 instances of PlexNewTranscoder found.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: Plex Media Scanner
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 0 instances of Plex Media Scanner found.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: PlexRelay
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 0 instances of PlexRelay found.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: Plex Relay
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 0 instances of Plex Relay found.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: EasyAudioEncoder
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 0 instances of EasyAudioEncoder found.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: Plex Tuner Service
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 0 instances of Plex Tuner Service found.
[13:19:54 INF][PmsMonitor][KillSupportingProcess] Looking for process: Plex Media Fingerprinter
[13:19:54 INF][PmsMonitor][KillSupportingProcess] 0 instances of Plex Media Fingerprinter found.
[13:56:19 DBG][PmsMonitor][WatchLog] PMS Log Path: C:\Users\Administrator\AppData\Local\Plex Media Server\Logs
[13:56:20 INF][PmsMonitor][GetPlexExecutable] Plex executable found using hard coded lookup
[13:56:20 INF][PmsMonitor][Start] Plex executable found at C:\Program Files\Plex\Plex Media Server\Plex Media Server.exe
[13:56:20 DBG][PmsMonitor][StartPlex] Disabling first run.
[13:56:20 DBG][PmsMonitor][DisableFirstRun] First run is: 0
[13:56:20 DBG][PmsMonitor][StartPlex] No plex defined, checking for running process.
[13:56:20 INF][PmsMonitor][StartPlex] Attempting to start Plex.
[13:56:20 INF][PmsMonitor][StartPlex] Plex Media Server version is 1.31.0.6654. Can use startup argument.
[13:56:20 INF][PmsMonitor][StartPlex] Plex Media Server Started.
[13:56:20 INF][PlexMediaServerService][OnStart] Plex Service Started.

Is there anything I'm missing that would be preventing the PlexService from starting automatically on server reboot? Or anything I could change and try to resolve this? Thanks!

cjmurph commented 1 year ago

Try setting it to automatic delayed. It doesn't do much on start, but If the system is busy or some other dependant service hasn't started yet, it might not be able to complete quick enough. The windows service manager has pretty tight return times for a start.

AnthonyBe commented 1 year ago

I'm pretty sure I've also tried that, but I'll give it another go just to be sure.

There is a lot going on on my server, and being a NAS (HP Microserver Gen 8) they aren't the fastest in starting everything up. I am also running Hyper-V on it with 2 VMs but that defaults to a delayed startup.

AnthonyBe commented 1 year ago

Finally had a reason to restart my server (Patch Tuesday) and setting the PlexService to Automatic (Delayed) seems to have worked this time.