lambda checks

69 views
Skip to first unread message

Alexander Vassilevski

unread,
Feb 29, 2016, 1:29:40 PM2/29/16
to god.rb
I'm trying to use god to restart apache whenever certain lambda conditions are met:

Enter code here...w.restart_if do |restart|
    restart.condition(:lambda) do |c|
        c.interval = 30.seconds
        c.lambda = lambda do
            # check that response times on apache threads are not >= 80% slow ( >4s but checks script for current values )
            system "/usr/local/bin/check-apache-slow-threads.rb > /tmp/check-apache-slow-threads.log"
            # if this is true, restart
            if $?.exitstatus > 0
                return true
            end

            # check that reply states of apache threads are not >= 90% "Waiting Reply"
            system "/usr/local/bin/check-apache-reply-states.rb > /tmp/check-apache-reply-states.log"
            # if this is true, restart
            if $?.exitstatus > 0
                return true
            end

            # i we don't have many slow threads or many waiting reply states, so don't restart
            return false
        end
    end
end

Anyway, the config file is accepted, so I don't see a syntax error but the commands don't seem to run ( the files /tmp/check-apache* don't seem to be created ) 

When I run the same ruby code ( the code for the lambda ) from a seperate file there is no issue but I'm not sure the lambda conditions work this way.

I'm using god god-0.13.7 ( as a part of the ruby 1.8 gems in centos 6).
Reply all
Reply to author
Forward
0 new messages