From 6078ad9864faae57cdbec71610e9bc4e7d8d1fcc Mon Sep 17 00:00:00 2001 From: Tom Werner Date: Fri, 17 Aug 2007 13:42:50 -0700 Subject: [PATCH] updated docs, remove daemons dependency; update manifest --- Manifest.txt | 10 ++++++---- Rakefile | 2 +- bin/god | 2 -- site/index.html | 27 +++++++++++++++++++++++++++ test/test_process.rb | 8 ++++++++ 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/Manifest.txt b/Manifest.txt index 08ac530..8c10f26 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -34,10 +34,12 @@ lib/god/sugar.rb lib/god/system/process.rb lib/god/timer.rb lib/god/watch.rb -test/configs/events/events.god -test/configs/events/simple_server.rb -test/configs/pid/pid.god -test/configs/pid/simple_server.rb +test/configs/child_events/child_events.god +test/configs/child_events/simple_server.rb +test/configs/child_polls/child_polls.god +test/configs/child_polls/simple_server.rb +test/configs/daemon_events/daemon_events.god +test/configs/daemon_events/simple_server.rb test/configs/real.rb test/configs/test.rb test/helper.rb diff --git a/Rakefile b/Rakefile index 6571b1d..faf6167 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,7 @@ Hoe.new('god', '0.3.0') do |p| p.summary = 'Like monit, only awesome' p.description = "God is an easy to configure, easy to extend monitoring framework written in Ruby." p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n") - p.extra_deps << ['daemons', '>=1.0.7'] + # p.extra_deps << ['daemons', '>=1.0.7'] p.spec_extras = {:extensions => ['ext/god/extconf.rb']} end diff --git a/bin/god b/bin/god index 9036a61..63d69c1 100755 --- a/bin/god +++ b/bin/god @@ -6,8 +6,6 @@ require 'rubygems' require 'optparse' require 'drb' -require 'daemons' - options = {:daemonize => true, :port => 17165} OptionParser.new do |opts| diff --git a/site/index.html b/site/index.html index e6edafa..1fc8da3 100644 --- a/site/index.html +++ b/site/index.html @@ -522,6 +522,33 @@ end +

Watching Non-Daemon Processes

+ +

Need to watch a script that doesn't have built in daemonization? No problem! God will daemonize and keep track of your process for you. If you don't specify a pid_file attribute for a watch, it will be auto-daemonized and a PID file will be stored for it in /var/run/god. If you'd rather have the PID file stored in a different location, you can set it in a God.init block at the top of your config:

+ +
God.init do |god|
+  god.pid_file_directory = '/home/tom/pids'
+end
+
+God.watch do |w|
+  # watch with no pid_file attribute set
+end
+ +

The directory you specify must be writable by god.

+ + + +

Loading Other Config Files

+ +

You should feel free to separate your god configs into separate files for easier organization. You can load in other configs using Ruby's normal load method, or use the convenience method God.load which allows for glob-style paths:

+ +
# load in all god configs
+God.load "/usr/local/conf/*.god"
+ +

God won't start it's monitoring operations until all configurations have been loaded.

+ + +

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/test_process.rb b/test/test_process.rb index 9194eb3..9954490 100644 --- a/test/test_process.rb +++ b/test/test_process.rb @@ -22,7 +22,9 @@ class TestProcess < Test::Unit::TestCase # These actually excercise call_action in the back at this point - Kev def test_call_action_with_string_should_fork_exec @p.start = "do something" + IO.expects(:pipe).returns([StringIO.new('1234'), StringIO.new]) @p.expects(:fork) + Process.expects(:waitpid) @p.call_action(:start) end @@ -42,7 +44,9 @@ class TestProcess < Test::Unit::TestCase [:start, :restart].each do |action| @p = God::Process.new(:name => 'foo') @p.stubs(:test).returns true + IO.expects(:pipe).returns([StringIO.new('1234'), StringIO.new]) @p.expects(:fork) + Process.expects(:waitpid) File.expects(:open).with(@p.default_pid_file, 'w') @p.send("#{action}=", "run") @p.call_action(action) @@ -51,7 +55,9 @@ class TestProcess < Test::Unit::TestCase def test_call_action_should_not_write_pid_for_stop @p.pid_file = nil + IO.expects(:pipe).returns([StringIO.new('1234'), StringIO.new]) @p.expects(:fork) + Process.expects(:waitpid) File.expects(:open).times(0) @p.stop = "stopping" @p.call_action(:stop) @@ -59,7 +65,9 @@ class TestProcess < Test::Unit::TestCase def test_call_action_should_mkdir_p_if_pid_file_dir_existence_test_fails @p.pid_file = nil + IO.expects(:pipe).returns([StringIO.new('1234'), StringIO.new]) @p.expects(:fork) + Process.expects(:waitpid) @p.expects(:test).returns(false, true) FileUtils.expects(:mkdir_p).with(God.pid_file_directory) File.expects(:open) -- 2.11.4.GIT