2013-03-01 32 views
0

我目前正在使用上帝启动6个进程工作进程。 Resque show表示他们已经开始工作,一切正常。有时候,工作流程将不再被识别,并且不再是已知的再造工人流程。我正在寻找的是重新启动该过程或让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开始。

让我知道是否需要提供其他内容或更清楚。感谢所有的帮助!

回答

0

我最终把redis放在工作人员的同一个盒子里,他们一直在正常工作。

相关问题