Sha256: 3f9d3dbe39b5adea5553934c6f02ed606e466de3585b86327461cc74bc2a1fd7

Contents?: true

Size: 997 Bytes

Versions: 69

Compression:

Stored size: 997 Bytes

Contents

God.watch do |w|
  w.name = "daemon-events"
  w.interval = 5.seconds
  w.start = 'ruby ' + File.join(File.dirname(__FILE__), *%w[simple_server.rb]) + ' start'
  w.stop = 'ruby ' + File.join(File.dirname(__FILE__), *%w[simple_server_stop.rb])
  w.pid_file = '/var/run/daemon-events.pid'
  w.log = File.join(File.dirname(__FILE__), 'daemon_events.log')
  w.uid = 'tom'
  w.gid = 'tom'
  
  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

69 entries across 69 versions & 21 rubygems

Version Path
god-0.7.0 test/configs/daemon_events/daemon_events.god
god-0.5.0 test/configs/daemon_events/daemon_events.god
god-0.7.5 test/configs/daemon_events/daemon_events.god
god-0.7.8 test/configs/daemon_events/daemon_events.god
god-0.7.13 test/configs/daemon_events/daemon_events.god
god-0.7.12 test/configs/daemon_events/daemon_events.god
god-0.7.3 test/configs/daemon_events/daemon_events.god
god-0.7.6 test/configs/daemon_events/daemon_events.god
god-0.7.7 test/configs/daemon_events/daemon_events.god