【发布时间】:2017-12-15 09:53:53
【问题描述】:
我们正在通过monit监控sidekiq进程。一旦 sidekiq 进程达到大约 2 GB 的内存,我们将重新启动该进程。我们用 90 秒的 tiemout 定义了启动和停止程序。但是停止程序正在失败(等待 90 秒的超时后)。
这是示例监控配置。
check process sidekiq
with pidfile /pathtopidfile
start program = "/bin/sh -c start sidekiq commmand" with timeout 90 seconds
stop program = "stop sidekiq command" with timeout 90 seconds
if totalmem is greater than 2GB for 3 cycles then restart
***## I need have some condition like this -> if "stop_program failed" then "do some action"***
end
P.S 我不知道捕获停止程序的正确语法在 monit 中失败。我检查了 monit 博客,但我不能。
【问题讨论】:
-
您好,我认为Monit 中不存在这样的功能。通常 init/service/daemon 脚本会自行处理超时并采取相应的措施。除了将您的停止脚本自定义为超时并自行采取措施之外,我无法预见在 Monit 级别有任何干净的解决方案
-
@TheCodeKiller -> 感谢您的 cmets。我已经按照您建议的方式解决了这个问题。我已经自定义了停止脚本(如果未能在超时内停止,则强制终止 sidekiq 进程。)
标签: monit