<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,7 +3,6 @@ Manifest.txt
 README.txt
 Rakefile
 bin/god
-bin/god-check
 examples/events.god
 examples/gravatar.god
 examples/single.god
@@ -15,6 +14,9 @@ lib/god.rb
 lib/god/behavior.rb
 lib/god/behaviors/clean_pid_file.rb
 lib/god/behaviors/notify_when_flapping.rb
+lib/god/cli/command.rb
+lib/god/cli/run.rb
+lib/god/cli/version.rb
 lib/god/condition.rb
 lib/god/conditions/always.rb
 lib/god/conditions/complex.rb</diff>
      <filename>Manifest.txt</filename>
    </modified>
    <modified>
      <diff>@@ -34,6 +34,7 @@ begin
       status                             show status of each task
       quit                               stop god
       terminate                          stop god and all tasks
+      check                              run self diagnostic
       
     Options:
   EOF</diff>
      <filename>bin/god</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,6 @@ module God
         @options = options
         @args = args
         
-        setup
         dispatch
       end
       
@@ -27,9 +26,13 @@ module God
       
       def dispatch
         if %w{load status log quit terminate}.include?(@command)
+          setup
           send(&quot;#{@command}_command&quot;)
         elsif %w{start stop restart monitor unmonitor}.include?(@command)
+          setup
           lifecycle_command
+        elsif @command == 'check'
+          check_command
         else
           puts &quot;Command '#{@command}' is not valid. Run 'god --help' for usage&quot;
           abort
@@ -114,6 +117,50 @@ module God
         end
       end
       
+      def check_command
+        Thread.new do
+          begin
+            event_system = God::EventHandler.event_system
+            puts &quot;using event system: #{event_system}&quot;
+            
+            if God::EventHandler.loaded?
+              puts &quot;starting event handler&quot;
+              God::EventHandler.start
+            else
+              puts &quot;[fail] event system did not load&quot;
+              exit(1)
+            end
+            
+            puts 'forking off new process'
+            
+            pid = fork do
+              loop { sleep(1) }
+            end
+            
+            puts &quot;forked process with pid = #{pid}&quot;
+            
+            God::EventHandler.register(pid, :proc_exit) do
+              puts &quot;[ok] process exit event received&quot;
+              exit(0)
+            end
+            
+            sleep(1)
+            
+            puts &quot;killing process&quot;
+            
+            ::Process.kill('KILL', pid)
+          rescue =&gt; e
+            puts e.message
+            puts e.backtrace.join(&quot;\n&quot;)
+          end
+        end
+        
+        sleep(2)
+        
+        puts &quot;[fail] never received process exit event&quot;
+        exit(1)
+      end
+      
       def lifecycle_command
         # get the name of the watch/group
         name = @args[1]</diff>
      <filename>lib/god/cli/command.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>bin/god-check</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>745c9b3835a07cccb936174cbf607235c69a4fcb</id>
    </parent>
  </parents>
  <author>
    <name>Tom Preston-Werner</name>
    <email>tom@mojombo.com</email>
  </author>
  <url>http://github.com/mojombo/god/commit/8906e12ccb19310d9bc7936e1f33ae7a475f11be</url>
  <id>8906e12ccb19310d9bc7936e1f33ae7a475f11be</id>
  <committed-date>2007-11-11T22:06:24-08:00</committed-date>
  <authored-date>2007-11-11T22:06:24-08:00</authored-date>
  <message>add god check to binary</message>
  <tree>18bcc25902f7b9872cb822ca60770183e99fbcfe</tree>
  <committer>
    <name>Tom Preston-Werner</name>
    <email>tom@mojombo.com</email>
  </committer>
</commit>
