From fbe92f2c886717717625ec89bd597fc45ed5268d Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 20 Aug 2012 11:31:20 -0400 Subject: [PATCH] make config even tighter --- skel/bin/god.conf | 49 ++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/skel/bin/god.conf b/skel/bin/god.conf index c851a32..d60f900 100644 --- a/skel/bin/god.conf +++ b/skel/bin/god.conf @@ -5,34 +5,47 @@ God.contact(:email) do |c| c.delivery_method = :sendmail end +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 + # 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}" - w.dir = '<%= current_path %>' - w.env = { - 'BUNDLE_GEMFILE' => '', - 'BUNDLE_BIN_PATH' => '', - 'RAILS_ENV' => '<%= stage %>', - 'RACK_ENV' => '<%= stage %>' - } - - w.log = "<%= shared_path %>/god.log" - w.start = "bundle exec thin -e <%= stage %> -p #{port} start" - w.start_if do |start| - start.condition(:process_running) do |c| - c.running = false - c.interval = 5.seconds - c.notify = "john" - end - end + shared_config(w) end end