I need a runit service for plex media server(from aur). The contents of systemd service are
[Unit]
Description=Plex Media Server
After=network.target
[Service]
EnvironmentFile=/etc/conf.d/plexmediaserver
ExecStart=/usr/lib/plexmediaserver/Plex\x20Media\x20Server
Type=simple
User=plex
Group=plex
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=multi-user.targe
How to include the extra info as environmentfile/user/group etc in the runit service
Hi dancaer69
For the conf file a construction like this is possible:
[ -r conf ] && . ./conf
For user/group:
exec chpst -u "$user:$groups"
Thanks, but I don't understand how to use them. Especially the conf part, I don't know how modify it to point to /etc/conf.d/plexmediaserver.
About the user/group part I found a page about "chpst", so I think that in my case it will be like this:
exec chpst -u "plex.plex"
EDIT:
I found this:
https://rubyists.github.io/2011/05/02/runit-for-ruby-and-everything-else.html
So, based on above example I'm thinking this:
envfile=/etc/conf.d/plexmediaserver
exec chpst -e $envfile -u plex.plex /usr/lib/plexmediaserver/Plex\ Media\ Server
Is this correct?
Almost.
Since
/etc/conf.d/plexmediaserver is a file and not a directory, I'd put it like this:
#!/bin/sh
. /etc/conf.d/plexmediaserver
exec chpst -u plex:plex /usr/lib/plexmediaserver/Plex\ Media\ Server
(Note the
: (colon) for user:group, not
. (point).)
Thanks. This should work, but the service always fail to run. If I manually run the script I get error about:
PMS: failure detected. Read/write access is required for path: /root/Library/Application Support/Plex Media Server
This directory doesn't exist. I have only in my user's home this directory(probably because I manually run it before. This happens and if I use my user' s name instead of plex. I also tried to move this directory to /root and change owner to plex. Also I gave read/write access to this dir to plex group and to anyone, but I always get the same error.
Sounds like you are possibily missing an option telling which dir for the application to use or chpst not being used correct. Init services run as root, reason it is looking in /root