If you google, there are a lot of people who have a lot of problems with Plex Media Server on power cuts. My one was that if the plexmediaserver.pid isn’t cleaned up by clean shutdown then it remains forever, until manual intervention.
Basically:
Aug 20 05:58:17 linux-server systemd[1]: Started Plex Media Server.
Aug 20 05:58:17 linux-server Plex Media Server[2034]: Plex Media Server is already running. Will not start...
Aug 20 05:58:17 linux-server systemd[1]: plexmediaserver.service: Main process exited, code=exited, status=1/FAILURE
Aug 20 05:58:17 linux-server systemd[1]: plexmediaserver.service: Failed with result 'exit-code'.
Behold the evil file:
root@linux-server:/var/lib/plexmediaserver/Library/Application Support/Plex Media Server# ls
Cache Codecs 'Crash Reports' Logs Media Metadata plexmediaserver.pid Plug-ins 'Plug-in Support' Preferences.xml
Whats inside the file:
root@linux-server:/var/lib/plexmediaserver/Library/Application Support/Plex Media Server# cat plexmediaserver.pid
993
Maybe there is a process number 993 somewhere? Nope:
So, I have fixed this in my instance by modifying the systemd startup script to delete any stale pid files before running Plex Media Server. But if you guys want a better general user experience then I would suggest you change Plex Media Server to not just check for the presence of the pid file but also check the contents actually points to a running instance of Plex Media Server.
Not everything is shutdown nicely in the real world, and assuming that it is causes great strife for end users.
I don’t think instructing people to go purchase hardware to work around lazy programming is a good approach. There are other situations where ungraceful shutdown can occur - crashes/intermittent hardware faults. Other service software can deal with stale pid files appropriately. Again, I’ve fixed it for me, I’m trying to help you improve your software.
Wait, I’m only a user. Don’t blame plex inc based on anything I say…
Just wait till intel introduces a hardware fault injector in the next line of ■■■■■■ CPU’s. The amount of file system corruption will be too damn high! I see DoS on the horizon…
Heh, sorry, I meant you in the plural, community sense, rather than you as a specific individual. I just noticed there is a lot of results for “plex stops working after power cut” on google. And it took me the better part of an hour to work out what was going on, and I’ve been using linux for decades. So yeah, devs should fix it
It’s just a vanilla PMS install on Ubuntu 22.04. You shouldn’t need to change anything to replicate the behavior, just install it then pull the power cord out of the back of the computer. The native app, running on physical hardware, no docker or VMs involved. The gid/uid for PMS and the pid file are the same - htpc which is the user & group that it runs as.