48 lines
1.3 KiB
Plaintext
48 lines
1.3 KiB
Plaintext
# since we're running god via bundler, we need to un-bundle any commands executed
|
|
def wrap_command(*args)
|
|
"bash -c 'unset BUNDLE_GEMFILE ; unset BUNDLE_BIN_PATH ; cd <%= current_path %> && #{args.join(' ')}'"
|
|
end
|
|
|
|
# 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
|
|
|
|
# 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|
|
|
# assign all watches to this group so personal_deity can stop/start them all at once
|
|
w.group = "<%= application %>"
|
|
w.name = "<%= application %>-thin-#{port}"
|
|
|
|
pid = "<%= shared_path %>/pids/thin.#{port}.pid"
|
|
command = "bundle exec thin -P #{pid} -p #{port}"
|
|
|
|
w.pid_file = pid
|
|
w.log = "<%= shared_path %>/god.log"
|
|
|
|
start = "#{command} -e <%= stage %> -d start"
|
|
w.start = wrap_command(start)
|
|
w.start_grace = 20.seconds
|
|
|
|
stop = "#{command} stop"
|
|
w.stop = wrap_command(stop)
|
|
|
|
w.restart = wrap_command("#{stop} && #{start}")
|
|
w.restart_grace = 20.seconds
|
|
|
|
w.start_if do |start|
|
|
start.condition(:process_running) do |c|
|
|
c.running = false
|
|
c.interval = 5.seconds
|
|
c.notify = "john"
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|