工作生活

ruby脚本监控puma内存重启策略

2019-07-01  本文已影响0人  ifree321
puts "== start checking..."
main_process_command = "ps aux --sort rss |grep tcp://0.0.0.0:8888"
main_process_result  = `#{main_process_command}`
main_process_lines   = main_process_result.split("\n")
main_process_pid     = main_process_lines.last.split(' ')[1]

command                 = "ps aux --sort rss | grep #{main_process_pid}"
result                  = `#{command}`
lines                   = result.split("\n")
last_line               = lines.last
splited_puma_last_line  = last_line.split(' ')

puts last_line

if splited_puma_last_line[5].to_i > 1350000
  puts "== located too many memory , phased-restart..."
  `#{"cd /opt/app/www.wondercv.com/current && ./restart_very_quickly"}`
else
  puts "-- ok"
end
上一篇下一篇

猜你喜欢

热点阅读