Monit is free and open source software that helps you keep track of processes. It can restart services that are not responding or that have crashed. You can use Systemd or daemontools for the same purpose. In this article, we'll show you how to install and configure monit to control processes on Debian or Ubuntu Linux.
To install, run the command on the server:
for Centos 7:
yum install epel-release yum update yum install monit systemctl enable monit systemctl start monit
for Debian-like system:
sudo apt install monit
Recommended configuration file
set daemon 1 with start delay 1 set logfile /var/log/monit.log set idfile /var/lib/monit/id set statefile /var/lib/monit/state set httpd port 2812 and use address localhost allow localhost include /etc/monit/conf.d/*
Configuration file for Astra service
check process astra with pidfile /var/run/astra.pid start program = "/etc/init.d/astra start" stop program = "/etc/init.d/astra stop"
Configuration file for simple Astra process
check process astra.pid with pidfile /var/run/astra.pid start program = "/bin/sh -c 'ulimit -n 65536; /usr/bin/astra -c /etc/astra/astra.conf -p 8000 --pid /var/run/astra.pid --log /var/log/astra.log --daemon'" stop program = "/bin/sh -c 'kill `cat /var/run/astra.pid`'"
Restart monit to apply changes:
systemctl restart monit
sudo /etc/init.d/monit restart
monit reload — reload configuration files
monit summary — short information
monit start astra — start Astra
monit stop astra — stop Astra
monit restart astra — restart Astra