User:Simon/Trim4/prototypes/calibre service file: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
You can easily create a service to run calibre at boot on a modern (systemd) based Linux system. Just create the file <code>/etc/systemd/system/calibre-server.service</code> with the contents shown below:
=== Creating a unit file ===
You can easily create a unit file for calibre to run on boot on a modern (systemd) based Linux system. This means it will also restart after a crash. Create the file <code>/etc/systemd/system/calibre-server.service</code> with the contents shown below:


    [Unit]
<pre>
    Description=calibre content server
[Unit]
    After=network.target
Description=Calibre.
   
After=syslog.target network.target
    [Service]
    Type=simple
    User=mylinuxuser
    Group=mylinuxgroup
    ExecStart=/opt/calibre/calibre-server "/path/to/calibre library directory"
   
    [Install]
    WantedBy=multi-user.target</code>


Change <code>mylinuxuser</code> and <code>mylinuxgroup</code> to whatever user and group you want the server to run as. This should be the same user and group that own the files in the calibre library directory. Note that it is generally not a good idea to run the server as root. Also change the path to the calibre library directory to suit your system. My calibre.service file looks like this:
[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/calibre-web
ExecStart=python cps.py
Restart=always


[[File:Bootleg calibre service.png|800px|frameless]]
[Install]
WantedBy=multi-user.target</pre>


Now run:
The <code>User</code> and <code>Group</code> should be the same ones that own the files in the calibre library directory. It's generally not a good idea to run the server as root. Also change the path to the calibre library directory to suit your system.
 
=== Starting the calibre-server service ===
Run:


<code>sudo systemctl start calibre-server</code>
<code>sudo systemctl start calibre-server</code>


to start the server. Check its status with:
to start the server.  
 
===Stopping the calibre-server service===
Stopping the service is as easy as running:
 
<code>sudo systemctl stop calibre-server</code>
 
===Checking the status of the calibre-server service===
Check its status with:


<code>sudo systemctl status calibre-server</code>
<code>sudo systemctl status calibre-server</code>


=== Enabling the calibre-server service to start at boot ===
To make it start at boot, run:
To make it start at boot, run:



Latest revision as of 11:56, 4 December 2019

Creating a unit file

You can easily create a unit file for calibre to run on boot on a modern (systemd) based Linux system. This means it will also restart after a crash. Create the file /etc/systemd/system/calibre-server.service with the contents shown below:

[Unit]
Description=Calibre.
After=syslog.target network.target

[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/calibre-web
ExecStart=python cps.py
Restart=always

[Install]
WantedBy=multi-user.target

The User and Group should be the same ones that own the files in the calibre library directory. It's generally not a good idea to run the server as root. Also change the path to the calibre library directory to suit your system.

Starting the calibre-server service

Run:

sudo systemctl start calibre-server

to start the server.

Stopping the calibre-server service

Stopping the service is as easy as running:

sudo systemctl stop calibre-server

Checking the status of the calibre-server service

Check its status with:

sudo systemctl status calibre-server

Enabling the calibre-server service to start at boot

To make it start at boot, run:

sudo systemctl enable calibre-server

Note

The calibre server does not need a running X server, but it does need the X libraries installed as some components it uses link against them.

The calibre server also supports systemd socket activation, so you can use that, if needed, as well.