Different restart commands based on the restart condition

104 views
Skip to first unread message

Nitesh Goel

unread,
May 7, 2012, 4:47:03 AM5/7/12
to god...@googlegroups.com
Hey Guys
I am monitoring a process where my restart command is based on the restart condition failed. E.g.

If memory usage too high:

w.restart = "command 1"

if cpu usage too high:

w.restart = "command 2"

Is there a way to configure a watch as such?

Thanks.

Nuno Valente

unread,
May 7, 2012, 6:23:09 PM5/7/12
to god...@googlegroups.com
Hi Nitesh. Sure you can.
You can find examples in the god homepage but i'll leave you one. You just need to wrap your conditions in a block.

w.restart_if do |restart|
        
        #Custom conditon
        restart.condition(:log_watcher) do |c|
          c.monitor_file w.log.to_s
          c.add_regexp(/.+OutOfMemory.+/)
        end
        #Built-in god conditon
        restart.condition(:memory_usage) do |c|
              c.above = 100.megabytes
              c.times = [3, 5] #3 out of 5 measurements 
        end
        #Built-in god conditon
        restart.condition(:cpu_usage) do |c|
          c.above = 98.percent
          c.times = 3 # 3 consecutive measurements
        end

end

Happy monitoring.

Best regards,
Nuno Valente.

--
You received this message because you are subscribed to the Google Groups "god.rb" group.
To view this discussion on the web visit https://groups.google.com/d/msg/god-rb/-/bgMHE_OZ-rcJ.
To post to this group, send email to god...@googlegroups.com.
To unsubscribe from this group, send email to god-rb+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/god-rb?hl=en.

Nitesh Goel

unread,
May 8, 2012, 9:59:19 PM5/8/12
to god...@googlegroups.com
Hi Nuno
Thanks. What I meant was this:

Currently I can specify a start, stop, and restart command in god.
I want to specify multiple different restart commands.

E.g.
Let's say I am monitoring the thin web server. If my box is out of memory, I want to restart with 5 servers, but if my box is out of cpu, I want to start with 3 servers (don't ask why .. contrived example).

So ..

w.restart1 = thin restart --servers 5
w.restart2 = thin restart --servers 3

How do I inject the restart command to run in the restart_if block?
To unsubscribe from this group, send email to god-rb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages