Sha256: 806ea18da985bc166e3e2557606385e1cd87d8b5c5c69508664057e97856551c

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

God.watch do |w|
  w.name = "nginx"
  w.interval = 30.seconds # default      
  w.start = "service nginx start"
  w.stop = "service nginx stop"
  w.restart = "service nginx restart"
  w.start_grace = 20.seconds
  w.restart_grace = 20.seconds
  w.pid_file = "/var/run/nginx/nginx.pid"
    
  w.behavior(:clean_pid_file)

  # determine the state on startup    
  w.transition(:init, { true => :up, false => :start }) do |on|      
    on.condition(:process_running) do |c|        
      c.running = true     
    end    
  end     

  # determine when process has finished starting    
  w.transition([:start, :restart], :up) do |on|      
    on.condition(:process_running) do |c|        
      c.running = true      
    end       
    # failsafe      
    on.condition(:tries) do |c|
      c.times = 8
      c.within = 2.minutes        
      c.transition = :start
    end
  end

  # start if process is not running    
  w.transition(:up, :start) do |on|      
    on.condition(:process_exits)    
  end     

  w.transition(:up, :restart) do |on|
      on.condition(:http_response_code) do |c|        
        c.host = 'localhost'        
        c.port = 80
        c.path = '/monitor.html'        
        c.code_is_not = 200        
        c.timeout = 10.seconds        
        c.times = [3, 5]      
      end    
  end

  # lifecycle    
  w.lifecycle do |on|      
    on.condition(:flapping) do |c|        
      c.to_state = [:start, :restart]        
      c.times = 5        
      c.within = 1.minute        
      c.transition = :unmonitored        
      c.retry_in = 10.minutes        
      c.retry_times = 5        
      c.retry_within = 2.hours      
    end    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Empact-deprec-1.99.21 lib/deprec/templates/god/god_nginx.erb