Monit - stop service and stay stopped?

David Kennedy picture David Kennedy · Sep 15, 2011 · Viewed 19.3k times · Source

I have a daemon which runs via the usual init.d/service scripts.

I have monit running which ensures these daemons are restarted if they crash.

I have a request that 'service foo stop' should stop the deamon, and because it was explicitly stopped, not a crash, monit should not restart it. How can I achieve this with monit?

I could have the service script's stop() routine call 'monit unmonitor' but this seems circular and wrong.

Thanks, Dave

Answer

jmonteiro picture jmonteiro · Nov 21, 2011

I think you should use monit stop foo instead of service foo stop. That way Monit is aware that the service didn't crash -- and won't restart it.