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:

    sudo apt install monit
    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 /etc/monit/conf.d/astra.conf:

    check process astra with pidfile /var/run/
        start program = "/etc/init.d/astra start"
        stop program = "/etc/init.d/astra stop"


    Configuration file for simple Astra process /etc/monit/conf.d/astra.conf:

    check process with pidfile /var/run/
        start program = "/bin/sh -c 'ulimit -n 65536;  /usr/bin/astra -c /etc/astra/astra.conf -p 8000 --pid /var/run/ --log /var/log/astra.log --daemon'"
        stop program = "/bin/sh -c 'kill `cat /var/run/`'"

    Restart monit to apply changes:

    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