Skip to main content
Topic: [H] Creating a user managed service (Read 93 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[H] Creating a user managed service

Hullo, after having read through various materials, I feel as though I am stuck.
My current attempt is listed below.

Code: [Select]
pacman -Ss <programme>

Here I create a system user which the service should run under. Sometimes installing a programme would create a user.
Code: [Select]
sudo useradd -m --home /opt/<programme> --system --user-group <programmeUser>

The run script, after creating the directory,  is
Code: [Select]
sudo mkdir /etc/runit/sv/<programmeService>
sudo nvim /etc/runit/sv/<programmeService>/run
  #!/bin/sh -e
  exec 2>&1
  exec chpst -u<programmeUser> /usr/bin/<programme>

Code: [Select]
sudo chmod 755 /etc/runit/sv/<programme>/run

Then, of course, enabling it
Code: [Select]
sudo ln -s /etc/runit/sv/<programmeService> /run/runit/service/

This service always returns status down. I have logged into the user as "sudo su <programmeUser>" as a test and launched "/usr/bin/<programme>", which launches without fault.
Furthermore, adding "runsvdir" to the exec line before the programme directory allows for the service to be up, but non responsive for some reason (should launch a webui via localhost:port).

I have successfully created a service with such a run script, however in that case the user was created with the installation of the programme (with the executable located in /opt and not /bin). As a result, I am unsure of why that one works and this does not.
The <programme> is "qbittorrent-nox", in case that is necessary information.

Any assistance is appreciated.

*minor command correction.

Re: [H] Creating a user managed service

Reply #1
Apologies for late response.
As your own user, have you tried running qbittorrent-nox from terminal? What's the result?
the runit guy on artix

Re: [H] Creating a user managed service

Reply #2
No problem.
When launching from the terminal it launches successfully, allowing me to connect via localhost:8112 (or 8080) with the default admin username/ password. As my own user the downloads directory is listed in /home, whereas under the service user it is listed in /opt/qbittorrent.

Re: [H] Creating a user managed service

Reply #3
Running chpst -u<user> qbittorrent-nox (as root since we're simulating a runit service here) manually returns

Could not create required directory '/root/.cache/qBittorrent/'.

So for some reason qbittorrent-nox still points to root even if we set the user to another user.

I'll see what I can do, but as a workaround, for now I recommend to use something else like transmission.
the runit guy on artix