A systemd service file for plerdwatcher and more

Posted: by Joe Johnston

So you have plerd all happy on your system. You run plerdwatch start and your off to the races. But what happens if your machine reboots? You need to restart both Dropbox and plerdwatcher.

If you are on a linux box that supports systemd, you’re in luck.

The following file will restart dropbox for you (you will need to change {USER} to username of the account running dropbox).

[Unit]
Description=Dropbox as a system service
After=local-fs.target network.target

[Service]
Type=simple
User={USER}
ExecStart=/usr/bin/env "/home/{USER}/.dropbox-dist/dropboxd"
Restart=on-failure
RestartSec=1

[Install]
WantedBy=multi-user.target

This should be copied in /etc/systemd/system/dropbox.service.

The plerdwatcher unit file is a little more involved since on my machine, I run plerd using plenv. Here is the file:

[Unit]
Description=Plerd daemon that monitors incoming posts and handles webmentions
Requires=network.target
After=network.target

[Service]
Type=forking
TasksMax=infinity
User={USER}
WorkingDirectory=/home/{USER}/src/plerd
ExecStart=/bin/bash -lc "cd /home/{USER}/src/plerd && PERL5LIB=/home/{USER}/src/plerd/local/lib/perl5 bin/plerdwatcher start"
ExecStop=/bin/bash -lc "cd /home/{USER}/src/plerd && PERL5LIB=/home/{USER}/src/plerd/local/lib/perl5 bin/plerdwatcher stop"
Restart=always

[Install]
WantedBy=multi-user.target

As with the previous file, you will need to replace {USER} with your account name. My installation of plerd is in my home directory in a directory called ‘src’. Inside of the plerd folder, I have a local directory containing Perl libraries needed for Plerd built for the version of Perl I run plerd with (5.26.1).

You may need to tinker with this scripts a bit, but this should help you get started.