5-2: Configure systemd
For production use, using tmux to run Pocket is not recommended. A better option in production is to setup a Linux service using a service manager such as systemd.
Creating a systemd service in Linux
To setup a systemd service for Pocket, do the following:
Open nano and create a new file called
pocket.servicesudo nano /etc/systemd/system/pocket.serviceAdd the following lines to the file:
[Unit]
Description=Pocket service
After=network.target
Wants=network-online.target systemd-networkd-wait-online.service
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
Restart=on-failure
RestartSec=5s
User=pocket
ExecStart=/home/pocket/go/bin/pocket start
ExecStop=/home/pocket/go/bin/pocket stop
[Install]
WantedBy=default.targetMake sure the
Useris set to the user that will run the Pocket service.Make sure the
ExecStartandExecStoppaths are set to the path for the Pocket binary.Save the file with Ctrl+O and then return.
Exit nano with Ctrl+X.
Reload the service files to include the pocket service.
sudo systemctl daemon-reloadStart the pocket service.
sudo systemctl start pocket.serviceVerify the service is running.
sudo systemctl status pocket.serviceStop the pocket service.
sudo systemctl stop pocket.serviceVerify the service is stopped.
sudo systemctl status pocket.serviceSet the service to start on boot.
sudo systemctl enable pocket.serviceVerify the service is set to start on boot.
sudo systemctl list-unit-files --type=serviceStart the pocket service.
sudo systemctl start pocket.service
Other systemctl commands
To restart the service:
sudo systemctl restart pocket.serviceTo prevent the service from starting on boot:
sudo systemctl disable pocket.serviceTo see mounted volumes:
sudo systemctl list-units --type=mountNote: If your pocket data is on a separate partition, you can use the following command to in the
pocket.servicefile to mount it before the pocket service starts.After=network.target mnt-data.mountThis ensures that the network is up and the volume is mounted before the pocket service starts.
Viewing the logs
To view the logs for the pocket service, do the following:
sudo journalctl -u pocket.service
To view just the last 100 lines of the logs (equiv. tail -f), do the following:
sudo journalctl -u pocket.service -n 100 --no-pager
Finding Errors
There are a few ways to find errors in the logs.
sudo journalctl -u pocket.service | grep -i error