Sha256: 5e8e19fffeb3de290aeb758b20a24954d22dcd707e92d0a6907067397e18aa67

Contents?: true

Size: 935 Bytes

Versions: 3

Compression:

Stored size: 935 Bytes

Contents

God.watch do |w|
  w.name = "daemon-events"
  w.interval = 5.seconds
  w.start = '/usr/local/bin/ruby ' + File.join(File.dirname(__FILE__), *%w[simple_server.rb]) + ' start'
  w.stop = '/usr/local/bin/ruby ' + File.join(File.dirname(__FILE__), *%w[simple_server.rb]) + ' stop'
  w.pid_file = '/var/run/daemon-events.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 = 2
      c.transition = :start
    end
  end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
god-0.4.1 test/configs/daemon_events/daemon_events.god
god-0.4.3 test/configs/daemon_events/daemon_events.god
god-0.4.0 test/configs/daemon_events/daemon_events.god