【问题标题】:Monitoring resque with monit with RVM使用 RVM 监控 resque
【发布时间】:2012-09-26 04:48:14
【问题描述】:

我之前使用以下 Monit 脚本进行了 Monit 监控

check process resque_worker_production_QUEUE
  with pidfile /var/tmp/resque_production.pid
  start program = "/usr/bin/env HOME=/home/eg RACK_ENV=production PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd /apps/eg/production/current; nohup bundle exec rake environment resque:work RAILS_ENV=production QUEUE=mailer VERBOSE=1 PIDFILE=/var/tmp/resque_production.pid & >> log/resque_worker_production_QUEUE.log 2>&1'" as uid eg and gid eg
  stop program = "/bin/sh -c 'cd /apps/eg/production/current && kill -9 $(cat 

然后我改变了一些东西,最明显的是删除了系统范围的 rvm 安装,我假设在 /usr/local/ruby/bin 安装了 ruby​​。大约在这个时候,monit 无法再启动 resque。也许原因是其他原因,但我认为是这些卸载导致了损坏。

所以我查看了脚本并注意到 /usr/local/ruby/bin 不存在,所以我尝试将其更改为我认为应该指向的内容,因为我的 rvm 中的 ruby​​ 是唯一的/home/eg/.rvm/rubies/ruby-1.9.3-p194/bin

但这没有用。所以我google了一些,发现这个建议也没有用:

check process resque_worker_production_QUEUE
  with pidfile /var/tmp/resque_production.pid
  start program = "/bin/bash -l -c 'cd /apps/eg/production/current; nohup bundle exec rake environment resque:work RAILS_ENV=production QUEUE=mailer VERBOSE=1 PIDFILE=/var/tmp/resque_production.pid & >> log/resque_worker_production_QUEUE.log 2>&1'" as uid eg and gid eg

我在日志中得到的只是:

[UTC Oct  5 03:06:38] error    : 'resque_worker_production_QUEUE' process is not running
[UTC Oct  5 03:06:38] info     : 'resque_worker_production_QUEUE' trying to restart
[UTC Oct  5 03:06:38] info     : 'resque_worker_production_QUEUE' start: /bin/bash
[UTC Oct  5 03:07:08] error    : 'resque_worker_production_QUEUE' failed to start

所以我不确定如何进一步调试。有什么建议吗?

【问题讨论】:

  • 您的监控日志中有什么?您应该在那里查看确切的问题。

标签: ruby-on-rails ruby ubuntu resque monit


【解决方案1】:

可以肯定的是,你的 bash 文件中有 RVM 加载脚本吗? 比如:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

对我来说,它适用于:

check process <%= pid_name %>
  with pidfile <%= pid %>
  start program = "/bin/bash -c -l -i 'cd <%= current_path %> && NEWRELIC_ENABLE=false HOME=/home/<%= resque_user %> RAILS_ENV=<%= rails_env %> QUEUE=<%= queue %> PIDFILE=<%= pid %> BACKGROUND=yes VERBOSE=1 <%= fetch(:bundle_cmd, "bundle") %> exec rake resque:work >> <%= shared_path %>/log/resque.log 2>&1'" as uid <%= resque_user %> and gid <%= resque_group %> with timeout 180 seconds

我发现 -i 标志 不同,不确定是否需要,以及 env 变量的顺序

您是否检查过 resque 日志? (我看到的log/resque_worker_production_QUEUE.log)

要尝试的另一件事是在以 root(或其他监视用户)身份 ssh 到服务器后运行此命令,sudo su还不够,因为您已经加载了 rvm,所以最好从头开始尝试。它可以揭示一些错误。

还可以查看此页面 http://rvm.io/integration/cron 以获取提示

【讨论】:

    猜你喜欢
    • 2012-01-25
    • 2013-03-29
    • 2011-09-11
    • 2019-12-01
    • 2012-02-01
    • 2019-02-13
    • 2018-05-22
    • 2012-09-12
    • 1970-01-01
    相关资源
    最近更新 更多