Skip to main content
Topic: create runit service from systemd (Read 1342 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

create runit service from systemd

I need a runit service for plex media server(from aur). The contents of systemd service are
Code: [Select]
[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 




Re: create runit service from systemd

Reply #1
Hi dancaer69

For the conf file a construction like this is possible:
[ -r conf ] && . ./conf

For user/group:
exec chpst -u "$user:$groups"

Re: create runit service from systemd

Reply #2
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:
Code: [Select]
envfile=/etc/conf.d/plexmediaserver
exec chpst -e $envfile -u plex.plex /usr/lib/plexmediaserver/Plex\ Media\ Server
Is this correct?



Re: create runit service from systemd

Reply #3
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:
Code: [Select]
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:
Code: [Select]
#!/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).)
now only the dinit guy in artix

Re: create runit service from systemd

Reply #4
Thanks. This should work, but the service always fail to run. If I manually run the script I get error about:
Code: [Select]
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.

 

Re: create runit service from systemd

Reply #5
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