<divclass="cardback"><DOCUMENT_FRAGMENT><divclass="mw-parser-output"><divclass="thumb tright"><divclass="thumbinner"style="width:152px;"><aclass="image"href="https://pzwiki.wdka.nl/mw-mediadesign/images/thumb/8/82/Bl_announcement_poster.jpeg/720px-Bl_announcement_poster.jpeg"><imgalt=""class="thumbimage"decoding="async"src="https://pzwiki.wdka.nl/mw-mediadesign/images/thumb/8/82/Bl_announcement_poster.jpeg/320px-Bl_announcement_poster.jpeg"></a><divclass="thumbcaption"><divclass="magnify"><aclass="internal"href="File:Bl_announcement_poster.jpeg.html"title="Enlarge"></a></div>Poster announcing the bootleg library, July 2019</div></div></div>
<liclass="toclevel-2"><ahref="#Creating_a_unit_file"><spanclass="tocnumber">1.1</span><spanclass="toctext">Creating a unit file</span></a></li>
<liclass="toclevel-2"><ahref="#Starting_the_calibre-server_service"><spanclass="tocnumber">1.2</span><spanclass="toctext">Starting the calibre-server service</span></a></li>
<liclass="toclevel-2"><ahref="#Stopping_the_calibre-server_service"><spanclass="tocnumber">1.3</span><spanclass="toctext">Stopping the calibre-server service</span></a></li>
<liclass="toclevel-2"><ahref="#Checking_the_status_of_the_calibre-server_service"><spanclass="tocnumber">1.4</span><spanclass="toctext">Checking the status of the calibre-server service</span></a></li>
<liclass="toclevel-2"><ahref="#Enabling_the_calibre-server_service_to_start_at_boot"><spanclass="tocnumber">1.5</span><spanclass="toctext">Enabling the calibre-server service to start at boot</span></a>
<h3><spanclass="mw-headline"id="Creating_a_unit_file">Creating a unit file</span><spanclass="mw-editsection"><spanclass="mw-editsection-bracket">[</span><ahref="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-1"title="Edit section: ">edit</a><spanclass="mw-editsection-bracket">]</span></span></h3>
<p>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:
</p>
<pre>[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</pre>
<p>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.
</p>
<h3><spanclass="mw-headline"id="Starting_the_calibre-server_service">Starting the calibre-server service</span><spanclass="mw-editsection"><spanclass="mw-editsection-bracket">[</span><ahref="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-2"title="Edit section: ">edit</a><spanclass="mw-editsection-bracket">]</span></span></h3>
<h3><spanclass="mw-headline"id="Checking_the_status_of_the_calibre-server_service">Checking the status of the calibre-server service</span><spanclass="mw-editsection"><spanclass="mw-editsection-bracket">[</span><ahref="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-4"title="Edit section: ">edit</a><spanclass="mw-editsection-bracket">]</span></span></h3>
<p>Check its status with:
</p><p><code>sudo systemctl status calibre-server</code>
</p>
<h3><spanclass="mw-headline"id="Enabling_the_calibre-server_service_to_start_at_boot">Enabling the calibre-server service to start at boot</span><spanclass="mw-editsection"><spanclass="mw-editsection-bracket">[</span><ahref="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-5"title="Edit section: ">edit</a><spanclass="mw-editsection-bracket">]</span></span></h3>