Monit doesn't perform 'stop' on 'restart'

Issue #592 closed
Val V created an issue

I have a pretty simple scenario:

check process node matching "^node"
    group node
    start program = "/path/to/node.sh" as uid node
    stop program = "/bin/bash -c 'pkill -x node'"
    if does not exist
      then restart
    if 5 restarts within 5 cycles
      then alert
    depends on var

For some strange reason if I kill the process manually, monit would only execute start, but not stop followed by start as described in the doc:

Apr 17 19:51:30 [monit] 'node' process is not running_
Apr 17 19:51:30 [monit] 'node' trying to restart_
Apr 17 19:51:30 [monit] 'node' start: '/path/to/node.sh'_
Apr 17 19:51:51 [monit] 'node' process is not running_
Apr 17 19:51:51 [monit] 'node' trying to restart_
Apr 17 19:51:51 [monit] 'node' start: '/path/to/node.sh'_

I also tried something very simple for the stop command like /bin/touch /tmp/monit.log -- no success.

Monit 5.20.0.

Comments (2)

  1. Tildeslash repo owner

    It's not bug - if the process doesn't exist, Monit skips the stop action during restart, as the process is stopped already.

    If you need to always perform some cleanup during restart, you can define standalone restart program:

    start program = ...
    stop program = ...
    restart program = ...
    
  2. Log in to comment