【问题标题】:Resque command works from terminal but not via bluepillResque 命令可从终端运行,但不能通过 bluepill
【发布时间】:2012-05-03 21:17:51
【问题描述】:

我正在尝试使用 bluepill 来监控我的 resque 工作人员。

如果我以 root 用户身份从我的 rails root 运行此命令,它会启动 resque worker ok。

cd /var/www/domain.com/current; RAILS_ENV=production QUEUE=* bundle exec rake resque:work

但是当我尝试使用 bluepill 运行它时,它只是一直在尝试启动它并且不会给我一个错误。

这是我的 bluepill 日志,显示它正在尝试......!

W, [2011-07-12T22:58:21.640467 #19267]  WARN -- : [domain.com:resque] Executing start command: cd /var/www/domain.com/current; RAILS_ENV=production QUEUE=* bundle exec rake resque:work
I, [2011-07-12T22:58:21.754392 #19267]  INFO -- : [domain.com:resque] Going from down => starting

I, [2011-07-12T22:59:21.334300 #19267]  INFO -- : [domain.com:resque] Going from starting => down
W, [2011-07-12T22:59:22.339873 #19267]  WARN -- : [domain.com:resque] Executing start command: cd /var/www/domain.com/current; RAILS_ENV=production QUEUE=* bundle exec rake resque:work
I, [2011-07-12T22:59:22.479740 #19267]  INFO -- : [domain.com:resque] Going from down => starting

它一遍又一遍地这样做。

这是我的 .pill 文件过程

app.process("resque") do |process|
  process.start_command = "cd #{RAILS_ROOT}; RAILS_ENV=#{RAILS_ENV} QUEUE=* bundle exec rake resque:work"
  process.daemonize = true

  process.start_grace_time = 10.seconds
  process.stop_grace_time = 10.seconds
  process.restart_grace_time = 10.seconds
end

我已经尝试延长开始宽限时间,如果它没有在要求的时间内加载但没有产生任何影响。

请问有人可以帮忙吗?

提前致谢 瑞克

【问题讨论】:

    标签: ruby-on-rails-3 resque bluepill


    【解决方案1】:

    不适合使用 bundle exec(有点旧),但可以轻松编辑。

    这是我的生产环境 Bluepill AudioBox.fm 配置,经过实战测试,乐于分享。

    ENVIRONMENT = 'production'
    RAILS_ROOT  = ENV['RAILS_ROOT'] || "/var/www/myapp/current"
    
    Bluepill.application("myapp", :log_file => "/var/log/bluepill.log") do |app|
      app.uid = "ubuntu"
      app.gid = "ubuntu"
    
      4.times do |i|
        app.process("uploaders-#{i}") do |process|
          process.working_dir = RAILS_ROOT
          process.group = "resque"
          queues = "amazon_upload"
          process.start_command = "/usr/bin/env VERBOSE=true RAILS_ENV=#{ENVIRONMENT} QUEUE=#{queues} rake resque:work --trace"
          process.stop_command = <<-EOF
          kill -QUIT {{PID}}
          sleep_count=0
          while [ -e /proc/{{PID}} ]; do
            sleep 1
            let "sleep_count+=1"
            if [ $sleep_count -eq 60 ]; then
              kill -TERM {{PID}}
            fi
            if [ $sleep_count -ge 70 ]; then
              kill -KILL {{PID}}
            fi
          done
          EOF
    
          process.stdout = process.stderr = "#{RAILS_ROOT}/log/resque.log"
          process.pid_file      = "#{RAILS_ROOT}/tmp/pids/resque-uploader-#{i}.pid"
          process.daemonize     = true
          process.start_grace_time = 5.seconds
          process.stop_grace_time = 75.seconds
          process.restart_grace_time = 80.seconds
    
          process.checks :mem_usage, :below => 350.megabytes, :every => 1.minute, :times => 3
        end
      end
    end
    

    【讨论】:

    • 你真的应该考虑使用 resque-pool,如果你有很多队列处理不同的任务,它会大大简化事情并让你更好地控制队列。
    【解决方案2】:

    @kain 的回答解决了你的问题吗?我刚刚开始发生一些非常相似的事情,请参阅bluepill not detecting that processes have, in fact, started successfully, and so creates new ones

    【讨论】:

      【解决方案3】:

      您没有说您使用的是哪个版本的 bluepill,但我只是修复了一个错误,该错误体现在该行为中。 Pull request submitted.

      【讨论】:

        【解决方案4】:

        我用 capistrano + resque 得到了这种东西......

        在 ssh -> sudo service redis start, 启动

        通过 capistrano -> sudo service redis start,说命令有效但没有进程...

        【讨论】:

          猜你喜欢
          • 2019-06-05
          • 2015-06-23
          • 2012-09-05
          • 2020-09-07
          • 2017-01-25
          • 2021-01-17
          • 2021-02-17
          • 1970-01-01
          • 2018-01-11
          相关资源
          最近更新 更多