2

I am starting and stopping a process via monit with the following syntax:

stop program = "..." with timeout 90 seconds

Everything works well, except that Monit always reports failed to stop after exactly one minute:

From /var/log/monit.log:

[EST Nov 11 11:04:09] info     : 'myprocess' stop: /bin/su
[EST Nov 11 11:05:09] error    : 'myprocess' failed to stop
[EST Nov 11 11:05:10] info     : 'myprocess' stop action done

I obviously want it to wait 90 seconds, not 60 seconds. What am I doing wrong?

Manuel Meurer
  • 263
  • 3
  • 12

2 Answers2

1

Your Monit daemon check interval is probably 60 seconds, so the check cycle occurs before your timeout.

set daemon 60

Can you post your entire Monit config? Is there a reason you need a 90-second timeout to stop a process?

By default, Monit waits 30 seconds for start/stop commands when it's looking at the process listing. Can you try a shorter with timeout?

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • Yes, that's it! What would be a sensible value for this setting? I need such a long timeout because the process I am monitoring is a background job queue, and it might take 60 seconds or longer to let a job finish before restarting. – Manuel Meurer Nov 11 '14 at 17:35
  • How often do you wish for Monit to poll your system? Try 120 seconds if 2-minute intervals is good for you. – ewwhite Nov 11 '14 at 17:38
  • Well no... if I set a stop timeout of 90 seconds, I would need it to check exactly then. With a daemon timeout of 120 seconds, it will check after 120 seconds, no? – Manuel Meurer Nov 11 '14 at 17:42
  • Try it and see! – ewwhite Nov 11 '14 at 17:42
  • I tried 120 and 20 as daemon timeouts, same behavior with both settings. Confusing... – Manuel Meurer Nov 11 '14 at 17:58
1

Turns out this was a bug in Monit: https://bitbucket.org/tildeslash/monit/issue/109/failed-to-stop-always-after-60-seconds Updating to Monit >= 5.9 should fix the issue.

Manuel Meurer
  • 263
  • 3
  • 12