PlexDBRepair icon indicating copy to clipboard operation
PlexDBRepair copied to clipboard

Docker Plex Service Kill Command Update (LinuxServer.io)

Open AppliedEllipsis opened this issue 1 year ago • 9 comments

On the current LinuxServer.io Plex Docker container, the service kill command is now

s6-svc -d /run/service/svc-plex

The path has changed and the current script will fail to stop otherwise.

AppliedEllipsis avatar Aug 27 '24 15:08 AppliedEllipsis

@AppliedEllipsis

Cool. Thank you for letting me know. I'll update right away. Expect an update (Aug 28/29)

ChuckPa avatar Aug 28 '24 06:08 ChuckPa

I've never been able to get the script to stop plex correctly (in a linuxserver.io docker on unraid) and the command seems to change every time I need to run it.

Rest of the script is awesome and I've used it multiple times so hopefully this fixes it and the command stops changing.

And reading the install instructions I think I have the files in the wrong spot. They are supposed to be next to /config and mine are in there. Hopefully that is my main issue.

Chaotic avatar Aug 28 '24 12:08 Chaotic

@Chaotic

  1. Yes, put the script (DBRepair.sh) adjacent to /config
  2. This way, when you enter the container, you can then /DBRepair.sh stop auto start exit (or whatever you want to do)

ChuckPa avatar Aug 28 '24 18:08 ChuckPa

@AppliedEllipsis

I just created a new LSIO plex container.

This is what I see:

root@lsioplex:/# ls /var/run/service
s6-linux-init-shutdownd  s6rc-fdholder  s6rc-oneshot-runner  svc-cron  svc-plex
root@lsioplex:/#

Given you state /run versus /var/run, I have no problem adding support for that variant.

Can you confirm?

root@lizum:/home/chuck/docker# docker container list
CONTAINER ID   IMAGE                      COMMAND   CREATED          STATUS          PORTS     NAMES
640a44e2f8f9   lscr.io/linuxserver/plex   "/init"   20 seconds ago   Up 20 seconds             lsioplex

ChuckPa avatar Aug 28 '24 18:08 ChuckPa

The full sequence:

Error response from daemon: No such container: lsioplex
Unable to find image 'lscr.io/linuxserver/plex:latest' locally
latest: Pulling from linuxserver/plex
6e8bf31012d1: Pull complete 
df25a931801a: Pull complete 
28b450414d82: Pull complete 
4c2c72666bec: Pull complete 
725602409e45: Pull complete 
5c8ce404d500: Pull complete 
54051aeb1d85: Pull complete 
cd1298983271: Pull complete 
af93280dc8fc: Pull complete 
bb34ccde04c8: Pull complete 
Digest: sha256:968263aa295c92bbc4ad6a1cc848d0275a5154cecc1d88e5f2f3fed3123be523
Status: Downloaded newer image for lscr.io/linuxserver/plex:latest
640a44e2f8f91a3f7c1a13c3bdb424abc90e52e20d5b4e441193102391a269b3
[chuck@lizum docker.2018]$ sudo bash
root@lizum:/home/chuck/docker# docker container list
CONTAINER ID   IMAGE                      COMMAND   CREATED          STATUS          PORTS     NAMES
640a44e2f8f9   lscr.io/linuxserver/plex   "/init"   20 seconds ago   Up 20 seconds             lsioplex
root@lizum:/home/chuck/docker# docker exec lsioplex bash

ChuckPa avatar Aug 28 '24 18:08 ChuckPa

@AppliedEllipsis @Chaotic

I've updated the general path testing to look at both older and newer (?) path -- which I can't yet confirm in my own new container.

Please test the DBRepair.sh from this branch

https://github.com/ChuckPa/PlexDBRepair/tree/chuckpa/update-linuxserver-svc

ChuckPa avatar Aug 28 '24 18:08 ChuckPa

Hey, Both paths exist in the container, but the command does not actually stop plex unless s6-svc -d /run/service/svc-plex is used.

Testing that branch I get: ./DBRepair.sh: 738: Syntax error: "}" unexpected (expecting "fi")

But adding another fi ~ :664 does allow the script to run and it stops/starts plex in the container successfully.

AppliedEllipsis avatar Sep 04 '24 00:09 AppliedEllipsis

1, Yes, I forgot to close that with fi

  1. If both paths exist in the container, how can we determine which one is the correct one to use ? I have then as equal. last-wins, IF statements. I can make a if-then-else tree.

ChuckPa avatar Sep 04 '24 21:09 ChuckPa

For 2: I am not sure how you would other than maybe try one after the other instead of replacing.

It might have something to do with Docker Read-Only Root FS and s6 https://github.com/just-containers/s6-overlay#read-only-root-filesystem

Note that s6-overlay assumes that: /run exists and is writable. If it is not, it will attempt to mount a tmpfs there. /var/run is a symbolic link to /run, for compatibility with previous versions. If it is not, it will make it so. In general your default docker settings should already provide a suitable tmpfs in /run.

So maybe that logic.


Also in the Docker Container, PID 1 shows /run/service as the path for s6-svscan. Maybe you could query ps -fp 1 for that.

root           1  0.0  0.0    440     8 ?        Ss   Sep03   0:00 /package/admin/s6/command/s6-svscan -d4 -- /run/service
root          18  0.0  0.0    204     0 ?        Ss   Sep03   0:00 /package/admin/s6-linux-init/command/s6-linux-init-shutdownd -d3 -c /run/s6/basedir -g 3000 -C -B

AppliedEllipsis avatar Sep 09 '24 17:09 AppliedEllipsis

@ChuckPa I just wanted to let you know that the current script works with Unraid version 6.12.13 and Linuxserver/docker-plex version 1.41.0.8992-8463ad060-ls235.

I downloaded the script via cli directly into the container:

docker exec -it plex /bin sh

apt-get update

apt-get install git -y

##A few moments later....###

git clone https://github.com/ChuckPa/PlexDBRepair.git

cd "/config/Library/PlexDBRepair"

Then launched the script via "./PlexDBRepair.sh"

Able to select option #1 to stop PMS

Then run / select any other option of my choice including #2 which runs smoothly just takes time because in my instance "com.plexapp.plugins.library.blobs.db" = 975MB & "com.plexapp.plugins.library.db" = 1.08GB in size.

Once again, I thank you @ChuckPa and your team for all of your hard work behind the scenes.

If you all want any further info or detail please let me know here or via PM.

drumtechphoto avatar Sep 17 '24 00:09 drumtechphoto

Well isn't this problematic :smile:

For the life of me, I cannot figure out why these lines, which have worked for a long time now, suddenly fail.

      # Miscellaneous start/stop methods
      if [ -d "/var/run/service/svc-plex" ]; then
        HaveStartStop=1
        StartCommand="s6-svc -u /var/run/service/svc-plex"
        StopCommand="s6-svc -d /var/run/service/svc-plex"
      fi

      if [ -d "/run/service/svc-plex" ]; then
        HaveStartStop=1
        StartCommand="s6-svc -u /run/service/svc-plex"
        StopCommand="s6-svc -d /run/service/svc-plex"
      fi

      if [ -d "/var/run/s6/services/plex" ]; then
        HaveStartStop=1
        StartCommand="s6-svc -u /var/run/s6/services/plex"
        StopCommand="s6-svc -d /var/run/s6/services/plex"
      fi

I'm not testing for writeable. This test shows shows directories are seen through the link.

[chuck@lizum ~.2000]$ mkdir /tmp/a
[chuck@lizum ~.2001]$ ln -s /tmp/a a
[chuck@lizum ~.2002]$ [ -d a ] && echo directory
directory
[chuck@lizum ~.2003]$ ls -la a
lrwxrwxrwx 1 chuck chuck 6 Sep 16 23:21 a -> /tmp/a/
[chuck@lizum ~.2004]$ 

ChuckPa avatar Sep 17 '24 03:09 ChuckPa

@drumtechphoto

I'm glad it helped. There are a couple here which help me with this monster I've created. ( I had no idea it would be like this when started) lol

I've figured out how to do multiple-level 'undo' commands .
This would allow you to do anything you want then unwind all the way back to the beginning.

It sounds like fun but feels like superfluous fluff.

I use this in all my production and testing work at Plex (I use a lot of LXCs) I'm glad it's out there to help the thousands who've used it so far

ChuckPa avatar Sep 17 '24 03:09 ChuckPa

@drumtechphoto

I'm glad it helped. There are a couple here which help me with this monster I've created. ( I had no idea it would be like this when started) lol

I've figured out how to do multiple-level 'undo' commands . This would allow you to do anything you want then unwind all the way back to the beginning.

It sounds like fun but feels like superfluous fluff.

I use this in all my production and testing work at Plex (I use a lot of LXCs) I'm glad it's out there to help the thousands who've used it so far

I get it. Its been a task for sure but much appreciated. I have used the script on both Synology & Unraid which have both come as life savers thank to the help of yourself and your team. @ChuckPa

drumtechphoto avatar Sep 18 '24 02:09 drumtechphoto

@drumtechphoto

Is this still an issue?

ChuckPa avatar Nov 08 '24 04:11 ChuckPa

@drumtechphoto

Is this still an issue?

@ChuckPa I forgot about this, not still an issue for me. (have not had to run the tool in over a month)

Thank you for the follow up :smile:

drumtechphoto avatar Nov 11 '24 22:11 drumtechphoto

Thanks.

ChuckPa avatar Nov 11 '24 22:11 ChuckPa