2012-07-03 21:54:07 +00:00
|
|
|
# a default email contact for when a service dies and needs to be restarted
|
|
|
|
God.contact(:email) do |c|
|
|
|
|
c.name = "john"
|
|
|
|
c.to_email = "email@example.com"
|
|
|
|
c.delivery_method = :sendmail
|
|
|
|
end
|
|
|
|
|
2012-08-20 15:31:20 +00:00
|
|
|
def notifies(condition)
|
|
|
|
c.notify = "john"
|
|
|
|
end
|
|
|
|
|
|
|
|
def keep_process_running(w)
|
|
|
|
w.start_if do |start|
|
|
|
|
start.condition(:process_running) do |c|
|
|
|
|
c.running = false
|
|
|
|
c.interval = 5.seconds
|
|
|
|
notofies(c)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def shared_config(w)
|
|
|
|
w.group = "<%= application %>"
|
|
|
|
w.dir = '<%= current_path %>'
|
|
|
|
|
|
|
|
w.env = {
|
|
|
|
'BUNDLE_GEMFILE' => '',
|
|
|
|
'BUNDLE_BIN_PATH' => '',
|
|
|
|
'RAILS_ENV' => '<%= stage %>',
|
|
|
|
'RACK_ENV' => '<%= stage %>'
|
|
|
|
}
|
|
|
|
|
|
|
|
w.log = "<%= shared_path %>/god.log"
|
|
|
|
|
|
|
|
keep_process_running(w)
|
|
|
|
end
|
|
|
|
|
2012-07-03 21:54:07 +00:00
|
|
|
# example for a thin-powered app, which is what I use the most of
|
|
|
|
<%= thin_servers %>.times do |port_id|
|
|
|
|
port = <%= thin_port %> + port_id
|
|
|
|
|
|
|
|
God.watch do |w|
|
2012-07-04 02:42:58 +00:00
|
|
|
# assign all watches to this group so personal_deity can stop/start them all at once
|
2012-07-03 21:54:07 +00:00
|
|
|
w.name = "<%= application %>-thin-#{port}"
|
|
|
|
|
2012-08-20 15:29:26 +00:00
|
|
|
w.start = "bundle exec thin -e <%= stage %> -p #{port} start"
|
2012-07-03 21:54:07 +00:00
|
|
|
|
2012-08-20 15:31:20 +00:00
|
|
|
shared_config(w)
|
2012-07-03 21:54:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|