Running bliss via systemd

A few days ago I upgraded my home server to Ubuntu 18.04, largely because (1) it needed doing and (2) abcde is now a maintained package. I like abcde best out of all the command line rippers.

Once installed I wanted bliss to fix up missing metadata and fill in artwork. The home server is normally used as a test machine for bliss, and doesn't start on boot. I wanted bliss to run when the machine started, so I immediately looked for my old post about configuring Upstart. I was surprised to find out Upstart was no longer supported, and I would have to use systemd.

The main advantages of using something like systemd to manage the bliss service and run it at startup are:

  • Daemonize-ing the process comes for free, so no messing about with nohup or equivalent.
  • Configuration for the service is centralised in a .service file rather than having to write your own script to configure any parameters.
  • You don't have to edit system startup scripts yourself.
  • The configuration is all declarative and managed by the system, meaning you can configure dependencies on hardware and software without nasty coding.
  • Start, stop, restart and other service lifecycle events are issued in a consistent style across all services.

Fortunately changing to systemd turned out to be pretty easy. Here's what I had to do:

1. Create a bliss.service file

First, we create a bliss.service file in /etc/systemd/system/:

$ sudo nano /etc/systemd/system/bliss.service

Copy and paste this code into the file:

You will probably want to change the User setting to something relevant to you. Another useful setting is Environment which can be used to set environment variables processed by the bliss.sh startup script.

2. Check the service has been added

Just to check the service has been added, run:

$ sudo systemctl status bliss

You should get something like:

● bliss.service - bliss
   Loaded: loaded (/etc/systemd/system/bliss.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

If you get something like Failed to start bliss.service. Unit bliss.service not found then the service hasn't been registered correctly. Check the bliss.service file is inside /etc/systemd/system/ and also try issuing:

sudo systemctl daemon-reload

... and then try again.

3. Start bliss

To start bliss, issue:

$ sudo systemctl start bliss

systemd runs bliss as a daemon so you won't receive any feedback. To check the progress, run:

$ sudo journalctl -u bliss -f

This gives you the output from bliss:

Nov 01 14:09:36 bordeaux systemd[1]: Started bliss.
Nov 01 14:09:37 bordeaux bliss.sh[3686]: bliss version: 20181030
Nov 01 14:09:38 bordeaux bliss.sh[3686]: bliss has started at http://localhost:3220

If you issue the previous command without the -f switch the entire log will be shown, so if bliss is not starting you can find out what the issue is.

4. Daemonize!

Rather topical, given it's the day after Halloween...

To set bliss to start when your host starts, run this command:

$ sudo systemctl enable bliss

You'll get a message saying that when your machine transfers to multi-user mode (runlevel 3) bliss will be started:

Created symlink /etc/systemd/system/multi-user.target.wants/bliss.service → /etc/systemd/system/bliss.service.

Thanks to unsplash-logoSai Kiran Anagani for the image above.
tags: techie

The Music Library Management blog

Dan Gravell

I'm Dan, the founder and programmer of bliss. I write bliss to solve my own problems with my digital music collection.