这是我所做的神配置。
God.watch do |w|
pid_file = "#{Rails.root}/tmp/pids/delayed_job.pid"
w.pid_file = pid_file
pid = File.read(pid_file)
w.log = "#{Rails.root}/log/god.log"
w.name = "delayed_job"
w.dir = Rails.root
w.interval = 15.seconds
w.start_grace = 10.seconds
w.restart_grace = 10.seconds
w.start = "RAILS_ENV=production ruby #{Rails.root}/bin/delayed_job start"
w.stop = "RAILS_ENV=production ruby #{Rails.root}/bin/delayed_job stop"
w.restart = "RAILS_ENV=production ruby #{Rails.root}/bin/delayed_job restart"
w.env = { 'RAILS_ENV' => "production" }
w.behavior(:clean_pid_file)
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 60.seconds
c.running = false
end
end
# When to restart a running deamon?
w.restart_if do |restart|
restart.condition(:memory_usage) do |c|
c.above = 200.megabytes
c.times = [2,5]
end
restart.condition(:cpu_usage) do |c|
c.above = 90.percent
c.times = 2
end
end
end
当CPU负载较高时进入:cpu_usage 条件,但在内存负载高于200 MB时不进入:cpu_usage 条件。上面的脚本中有什么显然是错的,但是我无法发现? 或者还有什么我需要添加的东西?
答案 0 :(得分:0)
摘自上帝的文件
为了触发重启而导致测试失败的次数设置为次数。这可以是整数或数组。整数意味着它必须连续多次失败,而数组[x,y]意味着它必须在最后的y次测试中失败x次。
首先解析:cpu_usage 条件,因为其次值为2,这意味着在连续2次失败后,上帝将触发此条件。虽然:memory_usage 设置为[2,5],但这意味着它应该在5次检查中失败2次。