【问题标题】:How do I monitor (non-zero-downtime) Unicorn?如何监控(非零停机时间)独角兽?
【发布时间】:2013-09-26 17:13:23
【问题描述】:

我发现了很多关于监控 Unicorn 的相互矛盾的信息,人们说其他配置脚本是错误的,并发布了他们自己的。似乎没有 Just Works™ 的主要配置

我假设preload_app 和零停机时间部署是罪魁祸首。我很想拥有它,但现在我更感兴趣的是让监控运行,期间。所以目前我已经关闭了所有这些设置。

现在我正在使用capistrano-unicorn,这是一个非常棒的宝石。

它为我提供了重新加载独角兽所需的所有 capistrano 部署挂钩。该应用已成功部署。

我现在要做的主要事情是……

a) 确保 unicorn 在服务器故障/重启时自动启动

b) 监控 unicorn 以重新启动死亡/挂起/无论如何的工作人员。

如果我正在使用这个 gem,那么实现我的目标的最佳方法可能是什么(请记住,我不一定需要零停机时间)?

谢谢

【问题讨论】:

    标签: ruby-on-rails ruby nginx ruby-on-rails-4 unicorn


    【解决方案1】:

    Engine yard 使用Monit,它是一个非常小的实用程序,可以满足您的需求!

    这里是独角兽的配置:

    check process unicorn
      with pidfile /path/to/unicorn.pid
      start program = "command to start unicorn"
        as uid yourUID and gid yourGID
        stop program = "command to stop unicorn"
        as uid yourUID and gid yourGID
      if mem > 255.0 MB for 2 cycles then restart
      if cpu > 100% for 2 cycles then restart
    
      check process unicorn_worker0
      with pidfile /path/to/unicorn_worker_0.pid
      if mem > 255.0 MB for 2 cycles then exec "/bin/bash -c '/bin/kill -6 `cat /path/to/unicorn_worker_0.pid` && sleep 1'"
    ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 2013-04-12
      • 2017-10-06
      • 1970-01-01
      • 2012-09-17
      • 2012-05-27
      • 2014-08-04
      相关资源
      最近更新 更多