Using MONIT to Automatically Restart a Service
Introduction
One of the issues you might face in your home server, is that a service might fail for any reason, and until you manually restart that service, it does not work.
To solve this issue, you can use a package called MONIT. It monitors the services you want and as soon as they fail, it attempts to start them.
I found this very useful specially for my web server.
Installtion and Set Up
Here is how to install and set up MONIT.
sudo apt install monit
sudo nano /etc/monit/conf.d/nginx.conf
sudo nano /etc/monit/conf.d/nginx.conf
Here, we try to set this up for nginx service. Paste:
check process nginx with pidfile /var/run/nginx.pid
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
Restart MONIT to apply the changes:
sudo systemctl restart monit
Buy me a coffe?!
Comments
No comments yet!
Add a new comment: