[英]God is not monitoring delayed_job and restart it based on memory usage
这是我完成的配置。
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时,它不会这样做。 上面的脚本中有什么显然是错误的,但是我无法发现? 还是我需要添加更多内容?
上帝文件摘录
为了触发重新启动,测试失败的次数由时间设置。 这可以是整数或数组。 整数表示必须连续失败多次,而数组[x,y]表示必须在最后y次测试中失败x次。
:cpu_usage条件首先得到解决,因为它的时间值为2,这意味着连续2次失败后,上帝将触发此条件。 当:memory_usage设置为[2,5]时,意味着它应该在5次检查中两次失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.