【问题标题】:Getting Monit monitrc file to test Rails applications获取 Monit monitrc 文件来测试 Rails 应用程序
【发布时间】:2012-09-19 02:22:24
【问题描述】:

我正在尝试使用 Monit 来监控并在某些 Rails 应用程序崩溃时重新启动它们。这些应用程序使用 Sphinx。 Monit 不接受通常在 shell 中工作的命令。

monitrc 配置如下所示:

...
check process app_name
  with pidfile "/path/to/pidfile/searchd.production.pidfile"
  start program = sudo su user_name -c "cd /home/app_name/current
    && RAILS_ENV=production rake ts:start"
  stop program = sudo su user_name -c "cd /home/app_name/current
    && RAILS_ENV=production rake ts:stop"
...

访问 pidfile 的权限被拒绝,但如果我尝试:

with pidfile "sudo /path/to/pidfile/searchd.production.pidfile"

它不起作用。

同样,monit 不接受启动和停止程序 bash 命令。

我是否缺少明显的解决方法? 顺便说一句,我是菜鸟。

我也看过http://capitate.rubyforge.org/recipes/sphinx-monit.html#sphinx:monit:start,但不是很明白。

【问题讨论】:

    标签: ruby-on-rails ruby monit


    【解决方案1】:

    在调用rake 之前尝试放置bundle exec。像这样:

    start program = sudo su user_name -c "cd /home/app_name/current
      && RAILS_ENV=production bundle exec rake ts:start"
    stop program = sudo su user_name -c "cd /home/app_name/current
      && RAILS_ENV=production bundle exec rake ts:stop"
    

    这是我无法监控生产服务器上的puma 服务器和delayed_job 工作人员的主要原因。

    更新:

    我的工作示例:

    check process puma with pidfile <%= puma_pidfile %>
      start program = "/bin/su - ubuntu -c 'cd /home/ubuntu/apps/artvasion/current && bundle exec puma -C config/puma.rb'"
      stop program =  "/bin/su - ubuntu -c 'kill `cat /home/ubuntu/apps/artvasion/shared/pids/puma.pid`'"
      # ...monitoring stuff
    

    【讨论】:

    • 感谢 Dave,但我认为问题是特定于 Monits 受限语言,例如,我需要 /bin/bash su 而不是 su
    • 当然。我用我的 puma 配置更新了我的答案。它使用su 你描述的方式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多