Running Calibre Server as a service under systemd

Calibre is an excellent e-book management software and one if its best characteristics is that it can run as a server and export all its contents as OPDS catablog so I can browse my e-book collection from my iPad or my phone.
The problem was that I needed to start Calibre manually for the server to run and I did tend to forget that.
So the obvious solution is to run Calibre as a service using the brand new systemd.

1. Create /lib/systemd/system/calibre.service as

Description=Calibre Service

ExecStart=/usr/bin/calibre-server \
        --daemonize \
        --max-cover=600x800 \
        --max-opds-items=30 \
        --max-opds-ungrouped-items=100 \
        --username=calibre \
        --port=8888 \
        --pidfile=/var/run/ \


make sure you change the port you want to use as well as the path to where your calibre library resides.
Check that it is correctly configured by executing
systemctl start calibre.service
Calibre Server should start up correctly and you can check by using
systemctl status calibre.service

2. To enable the service to run on every start up simply execute
systemctl enable calibre.service
and that will create a symbolic link to the /etc/systemd/system/ directory so it will start every time you boot into multi-user mode (I suppose runlvl 3 and above in the old language ;-)

In the end it turned out to by much simpler than I imagined by there is major lack of information and examples in the web about using systemd. Distro man pages were definitely lacking info and the official man pages are equally lacking

Edit :
David Woodhouse send me a message with 2 good points.
As the script stands at the moment Calibre is running as root which is NOT. good but for my setup not that important. So create a user and group calibre and amend the script as follows

That will create all sorts of permissions problems mainly with the pid file which you can probably live without but I prefer to keep it.
Thanks for the pointer David.