Skip to content
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

Docker Plex Service Kill Command Update (LinuxServer.io) #172

Open
AppliedEllipsis opened this issue Aug 27, 2024 · 13 comments
Open

Docker Plex Service Kill Command Update (LinuxServer.io) #172

AppliedEllipsis opened this issue Aug 27, 2024 · 13 comments

Comments

@AppliedEllipsis
Copy link

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.

@ChuckPa
Copy link
Owner

ChuckPa commented Aug 28, 2024

@AppliedEllipsis

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

@Chaotic
Copy link

Chaotic commented Aug 28, 2024

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.

@ChuckPa
Copy link
Owner

ChuckPa commented Aug 28, 2024

@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
Copy link
Owner

ChuckPa commented Aug 28, 2024

@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
Copy link
Owner

ChuckPa commented Aug 28, 2024

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
Copy link
Owner

ChuckPa commented Aug 28, 2024

@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

@AppliedEllipsis
Copy link
Author

AppliedEllipsis commented Sep 4, 2024

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.

@ChuckPa
Copy link
Owner

ChuckPa commented Sep 4, 2024

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.

@AppliedEllipsis
Copy link
Author

AppliedEllipsis commented Sep 9, 2024

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

@drumtechphoto
Copy link

drumtechphoto commented Sep 17, 2024

@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.

@ChuckPa
Copy link
Owner

ChuckPa commented Sep 17, 2024

Well isn't this problematic 😄

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
Copy link
Owner

ChuckPa commented Sep 17, 2024

@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

@drumtechphoto
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants