I use watchdog to monitor my RPI. Do services go offline or the RPI is not responding, watchdog kicks in and restart the system. Now I also want watchdog to watch my Linbpq. This is possible with watchdog, watchdog looks at a PID file. As far as I know, no PID file is created when starting Linbpq.
Now there is a possibility that when starting Linbpq with systemd a command can be given so that a PID file is created.
This is my linbpq.service file from systemd
pd9q@packet:~ $ sudo cat /etc/systemd/system/linbpq.service [Unit] Description=Linbpq Daemon After=network.target After=direwolf.target StartLimitInterval=0 [Service] Type=simple Restart=always RestartSec=5 ExecStartPost=/bin/sh -c "echo $MAINPID > /home/pd9q/linbpq/run/linbpq.pid" ExecStart=/bin/bash /home/pd9q/linbpq/linbpq.start WorkingDirectory=/home/pd9q/linbpq [Install] WantedBy=multi-user.target Alias=linbpq.service
This command creates a linbpq.pid file, now it is possible that watchdog monitors linbpq.
ExecStartPost=/bin/sh -c "echo $MAINPID > /home/pd9q/linbpq/run/linbpq.pid"
pd9q@packet:~ $ sudo ls -l /home/pd9q/linbpq/run -rw-r--r-- 1 root root 4 Oct 14 18:36 linbpq.pid pd9q@packet:~ $
At the end of my watchdog configuration file (/etc/watchdog.conf) I have added the following line.
# Check if Linbpq is running pidfile = /home/pd9q/linbpq/run/linbpq.pid
Take a look at what happens when you stop Linbpq.
sudo systemctl stop linbpq.service
Yes the system is ReBoOtInG (I hoop)