title: Monitoring redis with god - monitoring conditions
body: <p>Im trying to monitor redis with god but god tries to restart it even though its already running. This is my .god script (ported from <a href="http://blog.thomasmango.com/post/636319317/resque-in-production" rel="nofollow">http://blog.thomasmango.com/post/636319317/resque-in-production</a>):</p>
  
  <pre><code># Redis
  %w{6379}.each do |port|
    God.watch do |w|
      w.name = "redis-server"
      w.interval = 30.seconds
      w.start = "/etc/init.d/redis-server start"
      w.stop = "/etc/init.d/redis-server stop"
      w.restart = "/etc/init.d/redis-server restart"
      w.start_grace = 10.seconds
      w.restart_grace = 10.seconds
  
      w.start_if do |start|
        start.condition(:process_running) do |c|
            c.interval = 5.seconds
            c.running = false
        end
      end
    end
  end
  </code></pre>
  
  <p>Now when I start god like this:</p>
  
  <pre><code>god -c /home/phlegx/workspace/projectx/config/god/config.god -D --log-level debug
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>I [2011-04-28 18:32:10]  INFO: Loading /home/phlegx/workspace/projectx/config/god/config.god
  I [2011-04-28 18:32:10]  INFO: Syslog enabled.
  I [2011-04-28 18:32:10]  INFO: Using pid file directory: /var/run/god
  I [2011-04-28 18:32:10]  INFO: Started on drbunix:///tmp/god.17165.sock
  I [2011-04-28 18:32:10]  INFO: redis-server move 'unmonitored' to 'up'
  D [2011-04-28 18:32:10] DEBUG: driver schedule #&lt;God::Conditions::ProcessRunning:0x000000020929d0&gt; in 0 seconds
  I [2011-04-28 18:32:10]  INFO: redis-server moved 'unmonitored' to 'up'
  I [2011-04-28 18:32:10]  INFO: redis-server [trigger] process is not running (ProcessRunning)
  D [2011-04-28 18:32:10] DEBUG: redis-server ProcessRunning [true] {true=&gt;:start}
  I [2011-04-28 18:32:10]  INFO: redis-server move 'up' to 'start'
  I [2011-04-28 18:32:10]  INFO: redis-server start: /etc/init.d/redis-server start
  D [2011-04-28 18:32:20] DEBUG: driver schedule #&lt;God::Conditions::ProcessRunning:0x000000020929d0&gt; in 0 seconds
  I [2011-04-28 18:32:20]  INFO: redis-server moved 'up' to 'up'
  I [2011-04-28 18:32:20]  INFO: redis-server [trigger] process is not running (ProcessRunning)
  D [2011-04-28 18:32:20] DEBUG: redis-server ProcessRunning [true] {true=&gt;:start}
  I [2011-04-28 18:32:20]  INFO: redis-server move 'up' to 'start'
  I [2011-04-28 18:32:20]  INFO: redis-server start: /etc/init.d/redis-server start
  
  D [2011-04-28 18:32:30] DEBUG: driver schedule #&lt;God::Conditions::ProcessRunning:0x000000020929d0&gt; in 0 seconds
  I [2011-04-28 18:32:30]  INFO: redis-server moved 'up' to 'up'
  I [2011-04-28 18:32:30]  INF (ProcessRunning)O: redis-server [trigger] process is not running
  D [2011-04-28 18:32:30] DEBUG: redis-server ProcessRunning [true] {true=&gt;:start}
  I [2011-04-28 18:32:30]  INFO: redis-server move 'up' to 'start'
  I [2011-04-28 18:32:30]  INFO: redis-server start: /etc/init.d/redis-server start
  </code></pre>
  
  <p>As you can see it always complains with:</p>
  
  <pre><code>INF (ProcessRunning)O: redis-server [trigger] process is not running
  </code></pre>
  
  <p>Does anyone know what this is might causing?</p>
  
  <p>The PID that god writes out to "/var/run/god/redis-server.pid" seems not to be the same as when I do a "ps":</p>
  
  <pre><code>ps aux | grep redis
  redis     7702  0.0  0.0   9876  1376 ?        Ss   18:00   0:01 /usr/bin/redis-server /etc/redis/redis.conf
  </code></pre>
  
  <p>Shouldn't the PID in "redis-server.pid" be the same as "ps" shows?</p>