God configuration file to monitor existing processes?

半城伤御伤魂 提交于 2019-12-23 03:07:45

问题


I am monitoring my redis server using God (a Ruby gem). However, my existing server may already has an instance of redis up. How can I be sure it monitors the existing Redis server process that is already up?

This is my God file for redis:

rails_root = ENV['RAILS_ROOT']
redis_root = "/usr/local/bin"

# Redis
%w{6379}.each do |port|
  God.watch do |w|
    w.name          = "redis"
    w.interval      = 30.seconds
    w.start         = "#{redis_root}/redis-server /etc/redis/redis.conf"
    w.stop          = "#{redis_root}/redis-cli shutdown"
    w.restart       = "#{w.stop} && #{w.start}"
    w.start_grace   = 10.seconds
    w.restart_grace = 10.seconds
    w.log           = File.join(rails_root, 'log', 'redis.log')
    w.keepalive(:memory_max => 5000.megabytes)
    w.start_if do |start|
      start.condition(:process_running) do |c|
          c.interval = 5.seconds
          c.running = false
      end
    end
  end
end

回答1:


To answer this question:

I put a w.pid_file = "SOMETHING" in my God file, and made sure this PID file was also set in the configuration file for Redis.




回答2:


You should also add:

w.pid_file = "Your_pid_file_name"

and then clean the pid file with

w.behaviour(:clean_pid_file)


来源:https://stackoverflow.com/questions/16426786/god-configuration-file-to-monitor-existing-processes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!