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?

On Monday, May 7, 2012 6:23:09 PM UTC-4, Valente wrote:
>
> 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.
>
> On Mon, May 7, 2012 at 9:47 AM, Nitesh Goel <[email protected]> wrote:
>
>> 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.
>>
>> -- 
>> 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 [email protected].
>> To unsubscribe from this group, send email to 
>> [email protected].
>> For more options, visit this group at 
>> http://groups.google.com/group/god-rb?hl=en.
>>
>
>

-- 
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/-/zBq4a4oUGMIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/god-rb?hl=en.

Reply via email to