Skip to content

Instantly share code, notes, and snippets.

@atmos
Created October 20, 2008 00:32
Show Gist options
  • Select an option

  • Save atmos/17980 to your computer and use it in GitHub Desktop.

Select an option

Save atmos/17980 to your computer and use it in GitHub Desktop.
MERB_ROOT = "/data/ninja/current"
MERB_ENV = 'production'
APPLICATION = 'ninja'
USER = 'cpanel'
ENV['HOME'] = '/home/cpanel'
%w{5000 5001 5002}.each do |port|
God.watch do |w|
w.uid = USER
w.gid = USER
w.name = "merb_#{APPLICATION}_#{port}"
w.group = APPLICATION
w.interval = 30.seconds
w.start = "#{MERB_ROOT}/gems/bin/merb -p #{port} -e #{MERB_ENV} -d -P /var/run/merb/#{APPLICATION}/merb.#{port}.pid -m /data/#{APPLICATION}/current -l debug -L /var/log/engineyard/merb/#{APPLICATION}/production.log >> /tmp/merb.tries.log 2>&1"
w.stop = "/usr/bin/merb -k #{port}"
w.start_grace = 10.seconds
w.restart_grace = 15.seconds
w.pid_file = File.join("/var/run/merb/#{APPLICATION}/merb.#{port}.pid")
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 5.seconds
c.running = false
end
end
w.restart_if do |restart|
restart.condition(:memory_usage) do |c|
c.above = 120.megabytes
c.times = [3, 5] # 3 out of 5 intervals
end
end
w.behavior(:clean_pid_file)
w.lifecycle do |on|
on.condition(:flapping) do |c|
c.to_state = [:start, :restart]
c.times = 5
c.within = 5.minute
c.transition = :unmonitored
c.retry_in = 10.minutes
c.retry_times = 5
c.retry_within = 2.hours
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment