मैं एक उत्पादन वेबसाइट पर रेस्क का उपयोग कर रहा हूं।ईश्वर रुकने वाले श्रमिकों को रोकें
जब मैं तैनात करता हूं, तो मैं चाहता हूं कि भगवान सभी श्रमिकों को रोक दें और फिर उन्हें पुनरारंभ करें क्योंकि कभी-कभी हम कक्षा के कोड को बदलते हैं और असफल नौकरियों की आवश्यकता होती है।
समस्या यह है कि जब मैं भगवान को रोकता हूं, तो रेक वास्तव में रुकता नहीं है, मजदूर अभी भी जिंदा रहते हैं और पुराने कोड के साथ काम करते हैं, जो मेरे लिए सभी प्रकार के मुद्दों को बनाता है।
जब भी मैं 'ईश्वर को समाप्त करता हूं' तो यह श्रमिकों को मार नहीं देगा।
अभी, मैं श्रमिकों को मारने के लिए एक शेल स्क्रिप्ट का उपयोग कर रहा हूं, लेकिन जब से मेरे पास एक सर्वर है, तो यह सभी उत्पादन सर्वरों पर गधे में बहुत दर्द है।
rails_env = ENV['RAILS_ENV'] || "production"
rails_root = ENV['RAILS_ROOT'] || "/mnt/data-store/html/gogobot/current"
num_workers = rails_env == 'production' ? 5 : 2
num_workers.times do |num|
God.watch do |w|
w.dir = "#{rails_root}"
w.name = "resque-#{num}"
w.group = "resque"
w.interval = 2.minutes
w.env = {"QUEUE"=>"duplicate_merging,facebook_wall_posts,generic,mailer,notifications,realtime,scoring_system,signup,social_graph_facebook,social_graph_foursquare,social_graph_twitter,user_info,user_score", "RAILS_ENV"=>rails_env, "PIDFILE" => "#{rails_root}/tmp/resque_#{w}.pid"}
w.pid_file = "#{rails_root}/tmp/resque_#{w}.pid"
w.start = "cd #{rails_root}/ && rake environment resque:work QUEUE=duplicate_merging,facebook_wall_posts,generic,mailer,notifications,realtime,scoring_system,signup,social_graph_facebook,social_graph_foursquare,social_graph_twitter,user_info,user_score RAILS_ENV=#{rails_env}"
w.log = "#{rails_root}/log/resque_god.log"
w.uid = 'root'
w.gid = 'root'
# restart if memory gets too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.above = 350.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
1.times do |num|
God.watch do |w|
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
w.start = "cd #{rails_root} && rake jobs:work"
w.uid = 'root'
w.gid = 'root'
# retart if memory gets too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.above = 300.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
मैं कैसे भगवान का उपयोग कर रेक नौकरियों रोक सकता है में किसी भी मदद का स्वागत करेंगे:
यह मेरा भगवान कॉन्फ़िग फ़ाइल है।
धन्यवाद।