And… systemd for dummies. Its not that terrible

Writing init scripts is a pain in the rear. Upstart was better but badly documented. And for all the fruit thrown at it, systemd isn’t that bad when it comes to the end user experience. I’ve been using supervisord to run the update daemon for ttrss. I’ve upgraded from 14.10 to 16.10, and supervisord broke. After spending much too long on the update, and getting saved by a friend who knows his way around a debugger, I felt it was the perfect time to scrap that and run it on systemd.

I started off by looking at a script someone else wrote. It has a few nice things, but lets see, I use a different version of php (potentially!), postgres and so on. Its a good starting point. I also looked at the official docs for RHEL7 . I figured starting after the database and networking made a ton of sense. I had to find the name of the postgres unit, the path to php(I run php7.0), and include my own path to ttrss. Restarting on failure would be nice, and while I didn’t quite grok that on the official docs,theĀ  U&L stack has a lovely question on this.


Putting all this together

Fire up

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

and lets build us a systemd unit.


ExecStart=/usr/bin/php /var/www/ttrss/update_daemon2.php


I had to find a few of the variables – I used systemctl status to find the name of the postgres service. I built the ExecStart line using which php7.0 to find the location of the file.

I want this starting as www-data(makes permissions simpler), and its set to always restart, and if it fails, to restart in 5 seconds.

The [install] block is default. Seems to work fine

And there you have it, a systemd unit for any ttrss setup you care to modify it for.


Leave a Reply

Your email address will not be published. Required fields are marked *