【问题标题】:Managing Resque workers with Monit on RBenv setup在 RBenv 设置上使用 Monit 管理 Resque 工作人员
【发布时间】:2012-08-19 03:03:14
【问题描述】:

我正在尝试设置 Monit 来管理 Resque 工作人员,但它无法开始说 /home/deployer/.rbenv/shims/bundle: line 4: exec: rbenv: not found 我已经检查过它是否以deployer 用户身份运行命令,如果我直接通过 SSH 复制并粘贴命令,一切正常。下面是我的监视器配置。谢谢!

检查进程 resque_worker_1 使用 pidfile CURRENT_PATH/tmp/pids/resque_worker_1.pid 启动程序 = "/usr/bin/env HOME=/home/deployer RACK_ENV=production PATH=/home/deployer/.rbenv/shims:/usr/local/bin:/usr/local/ruby/bin:/usr/ bin:/bin:$PATH /bin/sh -l -c 'cd CURRENT_PATH; bundle exec rake environment resque:work RAILS_ENV=production QUEUE=high,normal,low VERBOSE=1 PIDFILE=CURRENT_PATH/tmp/pids/resque_worker_1.pid >> CURRENT_PATH/log/resque_worker_.log 2>&1'" 作为 uid 部署者和 gid 管理员 stop program = "/bin/sh -c 'cd CURRENT_PATH && kill -9 $(cat tmp/pids/resque_worker_1.pid) && rm -f tmp/pids/resque_worker_1.pid; exit 0;'" 作为 uid 部署者和 gid 管理员 如果 totalmem 在 10 个周期内大于 300 MB 然后重新启动 # 吃掉内存? 组 resque_workers

【问题讨论】:

    标签: ruby-on-rails resque monit rbenv


    【解决方案1】:

    我看到这个主题是在 2012 年创建的,但我遇到了类似的问题,这个帖子在 google 上排名第一。

    问题在于 monit 启动命令具有受限 env(env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/sh 来模拟)。

    要将 monit 与 rbenv 一起使用,您必须在 bundle exec 命令之前指定正确的路径。

    PATH=/home/[USER]/.rbenv/bin:/home/[USER]/.rbenv/shims:$PATH bundle exec ...

    以独角兽为例:

    check process unicorn_dev with pidfile /home/wizville/app/dev.wizville.fr/shared/pids/unicorn.pid
      group dev
      start program =  "/bin/bash -c 'cd /home/wizville/app/dev.wizville.fr/current && PATH=/home/wizville/.rbenv/bin:/home/wizville/.rbenv/shims:$PATH bundle exec unicorn -c config/unicorn.rb -D'" as uid "wizville"
      stop program = "/bin/bash -c 'kill -s QUIT `cat /home/wizville/app/dev.wizville.fr/shared/pids/unicorn.pid`'"
      depends on mysql
    

    【讨论】:

      【解决方案2】:

      这对我有用。

      使用 pidfile 检查进程 app_resque_worker 启动程序 = "/usr/bin/env HOME=/home/subcaster RACK_ENV=production PATH=/home/subcaster/.rvm/rubies/ruby-2.0.0-p247/bin/ruby:/usr/local/bin: /usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c \'cd ; bundle exec rake environment resque:work RAILS_ENV=production 背景=yes QUEUE=* PIDFILE=\'"

      停止程序 = "kill -9 cat <%= resque_pid%> && rm -f "

      如果 totalmem 在 10 个周期内大于 2000 MB,则重新启动

      【讨论】:

        【解决方案3】:

        我不确定这是否有帮助,但在我的 monitrc 起始行中,我必须首先 su 到我想要运行的用户。我还没有尝试使用 uid 和 gid 标志来知道它是否工作良好,所以这可能是一个追问答案。

        我记得和你有同样的问题......一切都在命令行中工作,但不是当 monit 会做它的事情。

        例如,在我的monitrc 中,我使用以下内容监控arsendmail:

        #arsendmail_rails3 # 监视和发送来自 rails 应用程序的邮件的守护进程 使用 pidfile /var/www/rak/log/ar_sendmail.pid 检查进程 ar_sendmail 启动程序“/bin/su - mike && /bin/bash -c 'cd /var/www/rak && ar_sendmail_rails3 -b1000 -d -e production'” 停止程序“/bin/ps -ef | /bin/grep ar_sendmail_rails3 | /bin/grep -v grep | /usr/bin/awk '{ /usr/bin/print $2}' | /usr/bin/xargs /bin /杀死 -9"

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-01-25
          • 2012-10-05
          • 1970-01-01
          • 1970-01-01
          • 2011-08-29
          • 2011-12-10
          • 1970-01-01
          • 2012-04-24
          相关资源
          最近更新 更多