Skip to content

Commit

Permalink
fixed god binary exiting with -1; fixed god binary group control
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Aug 20, 2007
1 parent 6078ad9 commit cf502d6
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 19 deletions.
15 changes: 7 additions & 8 deletions Announce.txt
@@ -1,17 +1,18 @@
Subject: [ANN] god 0.3.0 released

Wow, there are some really big changes and improvements in this release of god. Most noticeable is a simplification of the config file. Sadly, we must say goodbye to the much loved God.meddle and promote God.watch to top level. This change allows you to easily load in other god config files and have them work as expected. There's even a God.load that takes a glob-style file path string and expands it to load multiple files.
Plenty of big changes and improvements in this release of god. Most noticeable is a simplification of the config file. Sadly, we must say goodbye to the much loved God.meddle and promote God.watch to top level. This change allows you to easily load in other god config files and have them work as expected. There's even a God.load that takes a glob-style file path string and expands it to load multiple files.

PID file support is now baked in so you don't have to set a pid_file attribute on any conditions. This also allows god to support processes that aren't already daemons. If you don't specify a PID file for the watch, god will auto-daemonize and keep track of your process for you! To use this feature, you must either run as root (pid files will be stored by default in /var/run/god) or set the pid_file_directory attribute in a God.init block (see docs).
PID file support is now baked in so you don't have to set the pid_file attribute on conditions anymore. This also allows god to support processes that aren't already daemons. If you don't specify a PID file for the watch, god will auto-daemonize and keep track of your process for you! To use this feature, you must either run as root (pid files will be stored by default in /var/run/god) or set the pid_file_directory attribute in a God.init block (see docs).

For anyone that had problems installing the 0.2.0 release because of the events system not compiling, god 0.3.0 will now allow you to install without event support. Most systems are capable of supporting events, but it requires some dedication to get the headers in place and make sure your kernel is new enough. To determine if you have event support you can run "sudo god -V" (this MUST be run as root on Linux, as netlink connector requires root permissions).
For anyone that had problems installing the 0.2.0 release because of the events system not compiling, god 0.3.0 will now allow you to install without event support. Most systems are capable of supporting events, but it requires some dedication to get the headers in place and make sure your kernel is new enough. To determine if your god installation has event support you can run "sudo god -V" (this MUST be run as root on Linux, as netlink connector requires root permissions).

Using the god binary you will now be able to control your watches from the command line. You can start/stop/restart/monitor/unmonitor watches at your demand.
Using the god binary you can now control your watches from the command line. You can start/stop/restart/monitor/unmonitor watches at your demand.

New watch attributes now available:
pid_file: sets the watch process' PID file location
uid/gid: start processes as someone else (requires root access)
group: assign a watch to a group
autostart: prevent auto start on god start
group: assign a watch to a group (to control them all at once)
autostart: prevent auto start on god start if false

Updated documentation is now available on the website:

Expand All @@ -34,8 +35,6 @@ INSTALL

sudo gem install god

* note: currently tested only on Redhat Linux and Darwin (won't work on Windows)


FEATURES

Expand Down
8 changes: 8 additions & 0 deletions History.txt
@@ -1,3 +1,11 @@
== 0.4.0

* Major Enhancements

* Bug Fixes
* Use exit!(0) instead of exit! in god binary to exit with code 0 (instead of default -1)
* Command line group control fixed

== 0.3.0 / 2007-08-17

* Fix netlink header problem on Ubuntu Edgy [Dan Sully]
Expand Down
13 changes: 5 additions & 8 deletions bin/god
Expand Up @@ -55,23 +55,20 @@ if options[:version]

# print version
puts "Version #{God::VERSION}"
exit!
exit!(0)
elsif options[:info]
require 'god'

puts "Version: #{God::VERSION}"
puts "Polls: enabled"
puts "Events: " + God::EventHandler.event_system

exit!
exit!(0)
elsif command = ARGV[0]
require 'god'

# a command was specified

# disable at_exit
# module God; def self.at_exit; end; end


# get the name of the watch/group
name = ARGV[1]

Expand All @@ -94,7 +91,7 @@ elsif command = ARGV[0]
abort "Command '#{command}' is not valid. Run 'god --help' for usage"
end

exit!
exit!(0)
else
# start god
if !options[:daemonize]
Expand Down Expand Up @@ -141,6 +138,6 @@ else

::Process.detach pid

exit!
exit!(0)
end
end
2 changes: 1 addition & 1 deletion lib/god.rb
Expand Up @@ -107,7 +107,7 @@ def self.watch
end

self.groups[w.group] ||= []
self.groups[w.group] << w.name
self.groups[w.group] << w
end

# register watch
Expand Down
1 change: 1 addition & 0 deletions test/configs/child_polls/child_polls.god
Expand Up @@ -6,6 +6,7 @@ God.watch do |w|
w.grace = 2
w.uid = 'tom'
w.gid = 'tom'
w.group = 'test'

w.start_if do |start|
start.condition(:process_running) do |c|
Expand Down
29 changes: 27 additions & 2 deletions test/test_god.rb
Expand Up @@ -52,26 +52,34 @@ def test_watch_should_register_processes
end

def test_watch_should_get_stored_by_group
a = nil

God.watch do |w|
a = w
w.name = 'foo'
w.group = 'test'
end

assert_equal({'test' => ['foo']}, God.groups)
assert_equal({'test' => [a]}, God.groups)
end

def test_watches_should_get_stored_by_group
a = nil
b = nil

God.watch do |w|
a = w
w.name = 'foo'
w.group = 'test'
end

God.watch do |w|
b = w
w.name = 'bar'
w.group = 'test'
end

assert_equal({'test' => ['foo', 'bar']}, God.groups)
assert_equal({'test' => [a, b]}, God.groups)
end

def test_watch_should_allow_multiple_watches
Expand Down Expand Up @@ -149,6 +157,23 @@ def test_control_should_raise_on_invalid_command
end
end

def test_control_should_operate_on_each_watch_in_group
God.watch do |w|
w.name = 'foo1'
w.group = 'bar'
end

God.watch do |w|
w.name = 'foo2'
w.group = 'bar'
end

God.watches['foo1'].expects(:monitor)
God.watches['foo2'].expects(:monitor)

God.control('bar', 'start')
end

# start

def test_start_should_check_for_at_least_one_watch
Expand Down

0 comments on commit cf502d6

Please sign in to comment.