【问题标题】:God-Resque Process in LimboLimbo 中的 God-Resque 过程
【发布时间】:2013-02-16 11:39:42
【问题描述】:

我目前正在使用 God 启动 6 个 resque 工作进程。 Resque 表明他们已经开始工作并且一切正常。有时,工作进程会失去识别并不再是已知的 resque 工作进程。我正在寻找的是一种重新启动该过程或让 resque-web 再次识别它的方法。奇怪的是它仍然在后台运行并分叉任务来处理它们,我可以看到 resque-web 上的数量减少了,但它并没有显示任何工作人员正在运行。我查看了他们的 stale.god 脚本,但这不起作用,因为该过程似乎在从 resque-web 识别中删除后继续检索工作。这是我的设置:

#resque-production.god

6.times do |num|
  God.watch do |w|
    w.name = "resque-#{num}"
    w.group = "resque"
    w.interval = 30.seconds
    w.env = { 'RAILS_ENV' => 'production' }
    w.dir = File.expand_path(File.join(File.dirname(__FILE__)))
    w.start = "bundle exec rake environment RAILS_ENV=production resque:workers:start"
    w.start_grace = 10.seconds
    w.log = "/var/www/loadmax/shared/log/resque-worker.log"

    # restart if memory gets too high
    w.transition(:up, :restart) do |on|
      on.condition(:memory_usage) do |c|
        c.above = 200.megabytes
        c.times = 2
      end
    end

    # determine the state on startup
    w.transition(:init, { true => :up, false => :start }) do |on|
      on.condition(:process_running) do |c|
        c.running = true
      end
    end

    # determine when process has finished starting
    w.transition([:start, :restart], :up) do |on|
      on.condition(:process_running) do |c|
        c.running = true
        c.interval = 5.seconds
      end

      # failsafe
      on.condition(:tries) do |c|
        c.times = 5
        c.transition = :start
        c.interval = 5.seconds
      end
    end

    # start if process is not running
    w.transition(:up, :start) do |on|
      on.condition(:process_running) do |c|
        c.running = false
      end
    end
  end
end 

下一个文件用于连接一个redis服务器并设置优先级。

#resque.rake 
require 'resque/tasks'
Dir.glob("#{Rails.root}/app/workers/*.rb") do |rb|
  require rb
end
task "resque:setup" => :environment do
  resque_config = YAML.load_file(Rails.root.join("config","resque.yml"))
  ENV['QUEUE'] = resque_config["priority"].map{ |x| "#{x}" }.join(",") if ENV['QUEUE'].nil?
end
task "resque:workers:start" => :environment do
  threads = []
  q = [1,2]
  resque_config = YAML.load_file(Rails.root.join("config","resque.yml"))
  threads << Thread.new(q){ |qs|
    %x[bundle exec rake environment RAILS_ENV=#{Rails.env} resque:work QUEUE=#{resque_config["priority"].map{ |x| "#{x}" }.join(",")} ]
  }
  threads.each {|aThread| aThread.join }
end

我一直在寻找解决方案,而僵尸进程、陈旧进程和退出进程似乎都不是解决方案。我使用god -c /path/to/god 开始。

如果我需要提供任何其他内容或更清楚,请告诉我。感谢大家的帮助!

【问题讨论】:

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


    【解决方案1】:

    我最终将 redis 与工作人员放在同一个盒子上,并且他们一直在正常运行。

    【讨论】:

      猜你喜欢
      • 2013-05-13
      • 2012-06-03
      • 1970-01-01
      • 2013-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多