Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 64 lines (57 sloc) 1.712 kb
4882cdb @jnewland god config for sample rails app
authored
1 RAILS_ROOT = ENV['RAILS_ROOT'] ||= "/var/www/apps/test/current"
2 RUBY = `which ruby`.chomp
3 MONGREL_RAILS = `which mongrel_rails`.chomp
4 RAILS_ENV = ENV['RAILS_ENV'] ||= 'production'
5 MONGRELS = 2
6 MONGREL_START_PORT= 3000
7 USER = GROUP = 'deploy'
8
9 require 'god_web'
10 GodWeb.watch(:port => 3003)
11
12 0.upto(MONGRELS-1) do |n|
13 port = MONGREL_START_PORT+n
14 God.watch do |w|
15 w.group = 'mongrels'
16 w.name = "mongrel_#{port}"
17 w.uid = USER
18 w.gid = GROUP
19 w.interval = 30.seconds
20 w.start = "#{RUBY} #{MONGREL_RAILS} start --environment #{RAILS_ENV} --chdir #{RAILS_ROOT} --port #{port}"
21 w.start_grace = 90.seconds
22 w.restart_grace = 90.seconds
23 w.log = File.join(RAILS_ROOT, "log/mongrel_#{port}.log")
24
25 w.start_if do |start|
26 start.condition(:process_running) do |c|
27 c.interval = 5.seconds
28 c.running = false
29 end
30 end
31
32 w.restart_if do |restart|
33 restart.condition(:memory_usage) do |c|
34 c.above = 50.megabytes
35 end
36
37 restart.condition(:cpu_usage) do |c|
38 c.above = 50.percent
39 c.times = 2
40 end
41
42 restart.condition(:http_response_code) do |c|
43 c.code_is_not = 200
44 c.host = 'localhost'
45 c.path = '/pulse/pulse'
46 c.port = port
47 c.timeout = 30.seconds
48 c.times = [2, 3]
49 end
50 end
51
52 w.lifecycle do |on|
53 on.condition(:flapping) do |c|
54 c.to_state = [:start, :restart]
55 c.times = 5
56 c.within = 5.minute
57 c.transition = :unmonitored
58 c.retry_in = 10.minutes
59 c.retry_times = 5
60 c.retry_within = 2.hours
61 end
62 end
63 end
64 end
Something went wrong with that request. Please try again.