Latest PMS 1.15.0.659-9311f93fd breaks current installs on debian

Preparing to unpack .../plexmediaserver_1.15.0.659-9311f93fd_amd64.deb ...
Removed /etc/systemd/system/multi-user.target.wants/plexmediaserver.service.
Unpacking plexmediaserver (1.15.0.659-9311f93fd) over (1.15.0.659-9311f93fd) ...
Setting up plexmediaserver (1.15.0.659-9311f93fd) ...
Created symlink /etc/systemd/system/multi-user.target.wants/plexmediaserver.service → /lib/systemd/system/plexmediaserver.service.
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for ureadahead (0.100.0-20) ...

This latest update has broken a running plex server because it does not honor the defaults and installs into a pre-defined path.

It does not honor /etc/default/plexmediaserver and should consider it during installation and runtime. The following can be added to the top of the [service] section in /lib/systemd/system/plexmediaserver.service

EnvironmentFile=/etc/default/plexmediaserver

As for installation path that is another consideration that needs to be looked at. If the server is using something other than the static path in the package their plex install will break.

UPDATE: I resolved my issues by doing the following:

mkdir /etc/systemd/system/plexmediaserver.service.d

Then adding the below content to /etc/systemd/system/plexmediaserver.service.d/override.conf

[Service]
EnvironmentFile=/etc/default/plexmediaserver

If I may provide a bit of clarity.

Since Aug 2016, when Ubuntu 16 was released with systemd, we migrated to it.
Initially Ubuntu/Debian had the location of the service file incorrect.
They have since corrected that error.

I have documented the standard way here.

The short form is:

  1. sudo systemctl edit plexmediserver and place your customizations there
    -or-
  2. Manually create /etc/systemd/system/plexmediaserver.service.d/override.conf (systemctl does this for you as well)

Thank you for the clarification. I urge the package maintainer to add an EnvironmentFile within systemd to manage values separately from editing the main service unit. During installation this file can be validated by the user with a diff to show any updates or changes needed by the package manager. The idea being to separate out statically typed values from installation.

Today is your lucky day. I am one of the packaging maintainers here at Plex.

I can add migration support for carrying EnvironmentFile= specifications forward from older environments but some of those created in the early Ubuntu/Debian days have been problematic to manage. Problematic in that I also attempt some level of validation to ensure I am migrating the correct information forward.

I will definitely look further into the use of override.conf versus local.conf and see how systemd handles when both are present (one of the many problems I often encounter)

1 Like

Great, thank you!

If I may clarify here. the contents of /lib/systemd/system/plexmediaserver.service
will be overwritten with each update because these are under the control of the package manager.

Only those files in /etc/systemd/system/plexmediaserver.service.d are left untouched.

Caution must also be given; Should one decide to make any changes which impact how PMS starts or is controlled, other than Environment, User, Group, or Umask, any failure of PMS to start is the user’s responsibility. It is programatically impossible to understand every user’s configuration intent in the limits of package installation script.

1 Like

No clarification needed, I completely understand. As stated, my hope is the package maintainer utilize EnvironmentFile in /lib/systemd/system/plexmediaserver.service and include an additional file for the defaults such as /etc/default/plexmediaserver or a similarly named default file. Users can then create their own /etc/systemd/system/plexmediaserver.service.d/override.conf if they desire to override the defaults as systemd interprets this file location to override the defaults.

What’s unclear to me is how service.d/* works in terms of order or keywords for filenames. This may also be something that’s not implemented in systemd yet. Such as ordering with 00-, 10- in other .d directories, or maybe it does work as I haven’t tested it yet.

I can’t use EnvironmentFile= in /lib/systemd/system/plexmediaserver.service because nothing exists to put in it.

The default service file contains everything as discrete values. I opted to do it this way to afford easiest means to override any single value.

The primary uses are:

  1. Plex metadata directory
  2. Username and/or group
  3. Umask for UID/GID permission management

Beyond those 3, there is nothing else to change.

As example:

[Service]
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/home/plexdata"
User=chuck
Group=media
Umask=0002

oops… said 3, there are 4 :slight_smile:

The Temp can also be specified in the override but is usually better done within PMS

Moving those items into a defaults file may assist automated upgrade applications and migrations between hosts. Not for all scenarios, but in my case it would have.

Essentially any item starting with “Environment=” and similar non-systemd specific variables such as the following:

PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )" 
PLEX_MEDIA_SERVER_INFO_DEVICE="PC" 
PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)" 
PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )" 
LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib

Those INFO values are dynamically constructed as the shell executes.
We have those values sent up so I can keep track of how many configuration permutations exist.

I get a periodic report so when someone tells me there is “ABC problem” with something on platform A, OS distro B, I can immediately triage the impact it has

If I were to place them in an Environment= string, they would not be evaluated. They would be passed into PMS in the raw, unevaluated, form you see there.

What I’m looking for are things like:

Ubuntu,  18.04.01,  X86_64 

Fron this, If there is a problem unique to a distro release, I can better focus on it rather than wasting time waiting and hoping to collect information.

/etc/defaults is processed by the shell, so anything there will be evaluated.

/etc/defaults is processed by the shell, so anything there will be evaluated.

Sadly, that is not true with systemd. It does not do bash/shell evaluation for things in Environment= it is simply passing the value as-is.

This is why we need to handle the INFO values in the same exec line that starts PMS.

but I’m not suggesting you use Environment=

/lib/systemd/system/tester.service

[Service]
EnvironmentFile=/etc/default/tester
ExecStart=/bin/sh -c 'echo "${test_value}" > /tmp/tester'
Type=simple
User=plex
Group=plex
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3

/etc/default/tester

test_value="$(uname -m)"

/tmp/tester

x86_64

UPDATE/EDIT: Tested to see if evaluation is done outside of /etc/default/ and it will work if the following file is used EnvironmentFile=/lib/systemd/system/tester.service.d/tester.conf

Further testing of override.conf, possible order of files evaluated in service.d would be interesting. Example test cases:

/etc/default/tester
test_value="$(uname -m)"
/lib/systemd/system/tester.service.d/00-test.conf
test_value="00"
/lib/systemd/system/tester.service.d/10-test.conf
test_value="10"
/lib/systemd/system/tester.service.d/local.conf
test_value="local"
/lib/systemd/system/tester.service.d/override.conf
test_value="override"

Thank you for that but we are actually working on a different mechanism.
In the near future, there will be no need for those variables as it will all be PMS internal.

1 Like

That’s great to hear. Makes a lot of sense to internalize it.

Thank you for taking the time to discuss it, I appreciate it!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.