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
開始。
讓我知道是否需要提供其他內容或更清楚。感謝所有的幫助!