From 36dc4f20df4da386889524910d5427c813fcf81b Mon Sep 17 00:00:00 2001 From: Tom Werner Date: Thu, 6 Sep 2007 10:24:02 -0700 Subject: [PATCH] change status interface to return hash instead of string --- bin/god | 6 +++++- lib/god.rb | 6 ++++-- site/index.html | 10 ++++++++++ test/configs/stress/stress.god | 1 - test/test_god.rb | 4 ++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bin/god b/bin/god index a95a639..bfd370c 100755 --- a/bin/god +++ b/bin/god @@ -106,7 +106,11 @@ elsif command = ARGV[0] puts "Done" elsif command == 'status' - puts server.status + watches = server.status + watches.keys.sort.each do |name| + state = watches[name][:state] + puts "#{name}: #{state}" + end elsif command == 'log' begin Signal.trap('INT') { exit!(0) } diff --git a/lib/god.rb b/lib/god.rb index 978391f..b9b3694 100644 --- a/lib/god.rb +++ b/lib/god.rb @@ -212,10 +212,12 @@ module God end def self.status + info = {} self.watches.map do |name, w| status = w.state || :unmonitored - "#{name}: #{status}" - end.join("\n") + info[name] = {:state => status} + end + info end def self.running_log(watch_name, since) diff --git a/site/index.html b/site/index.html index a4f0bda..aa5ccc0 100644 --- a/site/index.html +++ b/site/index.html @@ -591,6 +591,16 @@ God.load "/usr/local/conf/*.god" +

Getting Logs for a Single Watch

+ +

Sifting through the god logs for statements specific to a specific Watch can be frustrating when you have many of them. You can get the realtime logs for a single Watch via the command line:

+ +
$ sudo god log 'local-3000'
+ +

This will display the last 100 lines of log for the 'local-3000' Watch and update every second with new log messages.

+ + +

Extend God with your own Conditions

God was designed from the start to allow you to easily write your own custom conditions, making it simple to add tests that are application specific.

diff --git a/test/configs/stress/stress.god b/test/configs/stress/stress.god index 3a4fbfe..e8c8177 100644 --- a/test/configs/stress/stress.god +++ b/test/configs/stress/stress.god @@ -2,7 +2,6 @@ God.watch do |w| w.name = "stress-#{i}" w.start = 'ruby ' + File.join(File.dirname(__FILE__), *%w[simple_server.rb]) - w.stop = '' w.interval = 1 w.grace = 2 w.group = 'test' diff --git a/test/test_god.rb b/test/test_god.rb index 650c04b..7aac864 100644 --- a/test/test_god.rb +++ b/test/test_god.rb @@ -272,14 +272,14 @@ class TestGod < Test::Unit::TestCase w = God.watches['foo'] w.state = :up - assert_equal "foo: up", God.status + assert_equal({'foo' => {:state => :up}}, God.status) end def test_status_should_show_unmonitored_for_nil_state God.watch { |w| w.name = 'foo'; w.start = 'bar' } w = God.watches['foo'] - assert_equal "foo: unmonitored", God.status + assert_equal({'foo' => {:state => :unmonitored}}, God.status) end # running_load -- 2.11.4.GIT