mojombo / god

Ruby process monitor

Home Page:http://godrb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

God won't restarted died process inside docker

phuongnd08 opened this issue · comments

I'm having God monitor thin with this configuration:

RAILS_ROOT = File.expand_path "."

God.watch do |w|
  w.name = "thin"
  w.dir = RAILS_ROOT

  w.log = File.join(RAILS_ROOT, 'log/god-thin.log')

  w.interval = 30.seconds

  w.start = "bundle exec thin start -C config/thin.yml"

  w.start_if do |start|
    start.condition(:process_running) do |c|
      c.interval = 10.seconds
      c.running  = false
    end
  end

  w.restart_if do |restart|
    restart.condition(:memory_usage) do |c|
      c.interval = 20.seconds
      c.above = 400.megabytes
      c.times = [3, 5] # 3 out of 5 intervals
    end

    restart.condition(:cpu_usage) do |c|
      c.interval = 20.seconds
      c.above = 50.percent
      c.times = 5
    end
  end

  w.keepalive
end

And this is thin configuration: I tell thin not to go into daemon mode:

log: log/thin.log
max_conns: 1024
daemonize: false
max_persistent_conns: 1024

In a regular mac osx, I can see God restart thin whenever I send thin a QUIT signal. But inside a docker container, when I use nsenter to open the shell inside the container, and send thin a QUIT signal, God does not restart the process. Thoughts?

I have to resort to http_response_code to let thin restart thin properly, sigh