Setup Service on Linux - janeczku/calibre-web GitHub Wiki
Follow the instructions for the init system your distribution is using
Create /etc/init.d/calibre-web:
#!/sbin/openrc-run
description="Calibre-Web"
depend() {
need net
after firewall
}
# Calibre-Web does not know how to background itself
command_background=true
# Insert the command you decided to use to start calibre-web
command="/opt/calibre-web/bin/cps"
# Change if needed
command_args="-o /var/log/calibre-web.log"
# RC_SVCNAME variable contains the name of this service
pidfile="/run/${RC_SVCNAME}.pid"
# user:group the command should run under
command_user="calibreweb:calibreweb"Ensure file mode
doas chmod 0755 /etc/init.d/calibre-webAnd start the system
doas rc-service calibre-web startIf you want to get Calibre-Web started automatically after reboot follow this instructions. Create a file cps.service as root in the folder /etc/systemd/system with the following content:
Replace the elements in {} like User, ExecStart and WorkingDirectory with your username and file- and foldernames.
Find the location of the Calibre-Web starterfile cps, this should be something like /home/<user>/.local/bin/cps.
[Unit]
Description=Calibre-Web
[Service]
Type=simple
User={Username}
ExecStart={path to starterfile}
[Install]
WantedBy=multi-user.target
Another option is using {path to correct pythoninstance} -m cps in the ExecStart line of the starterfile. The correct python instance depends on how you installed Calibre-Web via pip (e.g. virtual environment, system interpreter).
[Unit]
Description=Calibre-Web
[Service]
Type=simple
User={Username}
ExecStart={path to python} {/PATH/TO/cps.py including cps.py}
WorkingDirectory={/PATH/OF/CPS.PY without cps.py}
[Install]
WantedBy=multi-user.target
nano /etc/systemd/system/cps.service
[Unit]
Description=Calibre-Web
[Service]
Type=simple
User=ubuntu
ExecStart=/opt/calibre-web/venv/bin/python3 /opt/calibre-web/cps.py
WorkingDirectory=/opt/calibre-web/
[Install]
WantedBy=multi-user.target
Enable the service.
sudo systemctl enable cps.service
Start the service.
sudo systemctl start cps.service
Check the status of the service or any errors.
sudo systemctl status cps.service