Systemd Services
For production use, running pocket in a tmux session isn't recommended. A better option to use a service manager like systemd to run and manage the pocket service.
In this section, we'll create a systemd service for pocket.
Creating a systemd service
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 Network Service
After=network.target
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
Restart=on-failure
RestartSec=5s
User=pocket
ExecStart=/usr/local/go/bin/pocket start
ExecStop=/usr/local/go/bin/pocket stop
[Install]
WantedBy=multi-user.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-reloadStop the pocket process if it is currently running.
pocket stopStart 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.service - To prevent the service from starting on boot:
sudo systemctl disable pocket.service
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
Troubleshooting
If you're the pocket.service doesn't start, the most likely cause is that the path to the pocket binary is not correct or the User is not set to the correct user.
To verify the path to the pocket binary, you can run pocket in tmux and then do the following:
- Get the pocket process id.
top -b -n 1 | grep pocket - Get the path to the
pocketbinary.readlink /proc/<pid>/exereplace
<pid>with the process id