Setting up as service (systemd)

Learn how to set up the PersonalMediaVault server as a systemd service.

This technical guide explains how to set up PersonalMediaVault as a service in a Linux machine using systemd.

Make sure to follow the installation guide on Linux before doing this. This guide expects you to have PersonalMediaVault already installed in your system.

The first step for creating a systemd service is to create an user for that service.

In order to create the user, run the following commands:

sudo groupadd pmv
sudo useradd -M pmv -g pmv
sudo usermod -L pmv

After you did this, now it’s time to create a folder to store the vault. In this guide we are going to use /var/pmv/vault.

Run the following commands:

sudo mkdir /var/pmv
sudo mkdir /var/pmv/vault
sudo chown -R pmv:pmv /var/pmv

Then, it’s time to create the service file, run the following command:

sudo nano /etc/systemd/system/pmv.service

Copy the following contents and save it:

[Unit]
Description=PersonalMediaVault
After=network.target auditd.service

[Service]
Type=simple
ExecStart=/usr/bin/pmvd --daemon --log-requests --skip-lock --vault-path /var/pmv/vault
User=pmv
Group=pmv
WorkingDirectory=/var/pmv/vault
Environment=FRONTEND_PATH=/usr/lib/pmv/www
Environment=FFMPEG_PATH=/usr/bin/ffmpeg
Environment=FFPROBE_PATH=/usr/bin/ffprobe
Environment=TEMP_PATH=/tmp/pmv
LimitNOFILE=infinity
LimitCORE=infinity
KillMode=process
StandardInput=null
StandardOutput=syslog
StandardError=syslog
Restart=always

[Install]
WantedBy=multi-user.target

Note: You may want to change some options. For that, make sure to check the following:

After you saved the service file, and exited the editor, run the following command to enable the service, so it runs every time the system starts:

sudo systemctl enable pmv

Then, you can start it:

sudo systemctl start pmv

After it was started, you can check the logs with journalctl. Example:

sudo journalctl -u pmv

You can also check the service status with:

sudo systemctl status pmv
Last modified October 19, 2024: Update pmv-cli manual (2ecfe71)