Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Announce.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ EXAMPLE
The easiest way to understand how god will make your life better is by looking at a sample config file. The following configuration file is what I use at gravatar.com to keep the mongrels running:

# run with: god -c /path/to/gravatar.god
#
#
# This is the actual config file used to keep the mongrels of
# gravatar.com running.

Expand All @@ -61,15 +61,15 @@ RAILS_ROOT = "/Users/tom/dev/gravatar2"
%w{8200 8201 8202}.each do |port|
God.watch do |w|
w.name = "gravatar2-mongrel-#{port}"
w.interval = 30.seconds # default
w.interval = 30.seconds # default
w.start = "mongrel_rails start -c #{RAILS_ROOT} -p #{port} \
-P #{RAILS_ROOT}/log/mongrel.#{port}.pid -d"
w.stop = "mongrel_rails stop -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
w.restart = "mongrel_rails restart -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
w.start_grace = 10.seconds
w.restart_grace = 10.seconds
w.pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")

w.behavior(:clean_pid_file)

w.start_if do |start|
Expand All @@ -78,19 +78,19 @@ RAILS_ROOT = "/Users/tom/dev/gravatar2"
c.running = false
end
end

w.restart_if do |restart|
restart.condition(:memory_usage) do |c|
c.above = 150.megabytes
c.times = [3, 5] # 3 out of 5 intervals
end

restart.condition(:cpu_usage) do |c|
c.above = 50.percent
c.times = 5
end
end

# lifecycle
w.lifecycle do |on|
on.condition(:flapping) do |c|
Expand Down
2 changes: 1 addition & 1 deletion History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@

* Minor Enhancement
* Allow extra args to pass through to config file

== 0.5.1 / 2007-10-08

* Bug Fixes
Expand Down
12 changes: 6 additions & 6 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
god
by Tom Preston-Werner
Kevin Clark (kqueue/netlink support)

http://god.rubyforge.org

== DESCRIPTION:
God is an easy to configure, easy to extend monitoring framework written

God is an easy to configure, easy to extend monitoring framework written
in Ruby.

Keeping your server processes and tasks running should be a simple part of
your deployment process. God aims to be the simplest, most powerful
Keeping your server processes and tasks running should be a simple part of
your deployment process. God aims to be the simplest, most powerful
monitoring application available.

== DOCUMENTATION:
Expand All @@ -24,7 +24,7 @@ Sign up for the god mailing list at http://groups.google.com/group/god-rb
== INSTALL:

$ sudo gem install god

== CONTRIBUTE:

Latest code is available at http://github.com/mojombo/god
Expand Down
16 changes: 8 additions & 8 deletions examples/events.god
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ RAILS_ROOT = ENV['GOD_TEST_RAILS_ROOT']
w.stop = "mongrel_rails stop -P #{RAILS_ROOT}/log/mongrel.#{port}.pid -c #{RAILS_ROOT}"
w.pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")
w.log = File.join(RAILS_ROOT, "log/commands.#{port}.log")

# clean pid files before start if necessary
w.behavior(:clean_pid_file)

# determine the state on startup
w.transition(:init, { true => :up, false => :start }) do |on|
on.condition(:process_running) do |c|
c.running = true
end
end

# determine when process has finished starting
w.transition([:start, :restart], :up) do |on|
on.condition(:process_running) do |c|
c.running = true
end

# failsafe
on.condition(:tries) do |c|
c.times = 8
Expand All @@ -43,21 +43,21 @@ RAILS_ROOT = ENV['GOD_TEST_RAILS_ROOT']
w.transition(:up, :start) do |on|
on.condition(:process_exits)
end

# restart if memory or cpu is too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.interval = 20
c.above = 50.megabytes
c.times = [3, 5]
end

on.condition(:cpu_usage) do |c|
c.interval = 10
c.above = 10.percent
c.times = 5
end

on.condition(:http_response_code) do |c|
c.host = 'localhost'
c.port = port
Expand All @@ -67,7 +67,7 @@ RAILS_ROOT = ENV['GOD_TEST_RAILS_ROOT']
c.times = [3, 5]
end
end

# lifecycle
w.lifecycle do |on|
on.condition(:flapping) do |c|
Expand Down
12 changes: 6 additions & 6 deletions examples/gravatar.god
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# run with: god -c /path/to/gravatar.god
#
#
# This is the actual config file used to keep the mongrels of
# gravatar.com running.

Expand All @@ -8,15 +8,15 @@ RAILS_ROOT = "/Users/tom/dev/gravatar2"
%w{8200 8201 8202}.each do |port|
God.watch do |w|
w.name = "gravatar2-mongrel-#{port}"
w.interval = 30.seconds # default
w.interval = 30.seconds # default
w.start = "mongrel_rails start -c #{RAILS_ROOT} -p #{port} \
-P #{RAILS_ROOT}/log/mongrel.#{port}.pid -d"
w.stop = "mongrel_rails stop -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
w.restart = "mongrel_rails restart -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
w.start_grace = 10.seconds
w.restart_grace = 10.seconds
w.pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")

w.behavior(:clean_pid_file)

w.start_if do |start|
Expand All @@ -25,19 +25,19 @@ RAILS_ROOT = "/Users/tom/dev/gravatar2"
c.running = false
end
end

w.restart_if do |restart|
restart.condition(:memory_usage) do |c|
c.above = 150.megabytes
c.times = [3, 5] # 3 out of 5 intervals
end

restart.condition(:cpu_usage) do |c|
c.above = 50.percent
c.times = 5
end
end

# lifecycle
w.lifecycle do |on|
on.condition(:flapping) do |c|
Expand Down
14 changes: 7 additions & 7 deletions examples/single.god
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ God.watch do |w|
w.stop = "mongrel_rails stop -P #{RAILS_ROOT}/log/mongrel.pid"
w.restart = "mongrel_rails restart -P #{RAILS_ROOT}/log/mongrel.pid"
w.pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")

# clean pid files before start if necessary
w.behavior(:clean_pid_file)

# determine the state on startup
w.transition(:init, { true => :up, false => :start }) do |on|
on.condition(:process_running) do |c|
c.running = true
end
end

# determine when process has finished starting
w.transition([:start, :restart], :up) do |on|
on.condition(:process_running) do |c|
c.running = true
end

# failsafe
on.condition(:tries) do |c|
c.times = 5
Expand All @@ -35,22 +35,22 @@ God.watch do |w|
w.transition(:up, :start) do |on|
on.condition(:process_exits)
end

# restart if memory or cpu is too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.interval = 20
c.above = 50.megabytes
c.times = [3, 5]
end

on.condition(:cpu_usage) do |c|
c.interval = 10
c.above = 10.percent
c.times = [3, 5]
end
end

# lifecycle
w.lifecycle do |on|
on.condition(:flapping) do |c|
Expand Down
6 changes: 3 additions & 3 deletions ext/god/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def create_dummy_makefile
puts "Missing 'sys/event.h' header"
fail = true
end

if fail
puts
puts "Events handler could not be compiled (see above error). Your god installation will not support event conditions."
Expand All @@ -31,15 +31,15 @@ def create_dummy_makefile
puts "You may need to install a header package for your system"
fail = true
end

unless have_header('linux/connector.h') && have_header('linux/cn_proc.h')
puts
puts "Missing 'linux/connector.h', or 'linux/cn_proc.h' header(s)"
puts "These are only available in Linux kernel 2.6.15 and later (run `uname -a` to find yours)"
puts "You may need to install a header package for your system"
fail = true
end

if fail
puts
puts "Events handler could not be compiled (see above error). Your god installation will not support event conditions."
Expand Down
36 changes: 18 additions & 18 deletions ext/god/kqueue_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ kqh_event_mask(VALUE klass, VALUE sym)
} else {
rb_raise(rb_eNotImpError, "Event `%s` not implemented", rb_id2name(id));
}

return Qnil;
}


VALUE
kqh_monitor_process(VALUE klass, VALUE pid, VALUE mask)
{
struct kevent new_event;
ID event;

u_int fflags = NUM2UINT(mask);

EV_SET(&new_event, FIX2UINT(pid), EVFILT_PROC,
EV_ADD | EV_ENABLE, fflags, 0, 0);

if (-1 == kevent(kq, &new_event, 1, NULL, 0, NULL)) {
rb_raise(rb_eStandardError, strerror(errno));
}

num_events = NUM_EVENTS;

return Qnil;
}

Expand All @@ -62,23 +62,23 @@ kqh_handle_events()
int nevents, i, num_to_fetch;
struct kevent *events;
fd_set read_set;

FD_ZERO(&read_set);
FD_SET(kq, &read_set);

// Don't actually run this method until we've got an event
rb_thread_select(kq + 1, &read_set, NULL, NULL, NULL);
rb_thread_select(kq + 1, &read_set, NULL, NULL, NULL);

// Grabbing num_events once for thread safety
num_to_fetch = num_events;
events = (struct kevent*)malloc(num_to_fetch * sizeof(struct kevent));

if (NULL == events) {
rb_raise(rb_eStandardError, strerror(errno));
}

nevents = kevent(kq, NULL, 0, events, num_to_fetch, NULL);

if (-1 == nevents) {
free(events);
rb_raise(rb_eStandardError, strerror(errno));
Expand All @@ -91,7 +91,7 @@ kqh_handle_events()
}
}
}

free(events);

return INT2FIX(nevents);
Expand All @@ -101,17 +101,17 @@ void
Init_kqueue_handler_ext()
{
kq = kqueue();

if (kq == -1) {
rb_raise(rb_eStandardError, "kqueue initilization failed");
}

proc_exit = rb_intern("proc_exit");
proc_fork = rb_intern("proc_fork");
m_call = rb_intern("call");
m_size = rb_intern("size");
m_deregister = rb_intern("deregister");

mGod = rb_const_get(rb_cObject, rb_intern("God"));
cEventHandler = rb_const_get(mGod, rb_intern("EventHandler"));
cKQueueHandler = rb_define_class_under(mGod, "KQueueHandler", rb_cObject);
Expand Down
Loading