【问题标题】:How to capture monit stop program failed when monit is restarting the processmonit重新启动进程时如何捕获monit stop程序失败
【发布时间】: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


【解决方案1】:

我认为 monit 中没有选项来捕获停止或启动程序的失败。所以我们必须在我们各自的程序中处理那些失败的案例。假设我的停止程序失败了,我必须找出失败的原因,并在停止程序本身中采取相应的措施。

我最初的问题是 Sidekiq 进程没有在超时内被杀死,所以停止程序失败了。为了解决这个问题,我在停止程序中进行了处理,如果 sidekiq 进程在超时时间内没有被杀死,则硬杀死该进程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-30
    • 1970-01-01
    • 1970-01-01
    • 2016-07-07
    • 2016-01-03
    • 1970-01-01
    • 2015-03-27
    • 1970-01-01
    相关资源
    最近更新 更多