Created
May 19, 2013 19:39
-
-
Save robdbirch/5608719 to your computer and use it in GitHub Desktop.
God Middleware Condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def middleware_up? | |
gps = God.status | |
applog @watch, :debug, "God Status: #{gps.inspect}" | |
(gps['mongo'][:state] == :up) and (gps['apollo'][:state] == :up) | |
end | |
class MiddlewareRunning < God::PollCondition | |
def initialize | |
super | |
LOG.level = God::Logger::DEBUG | |
end | |
def before | |
applog @watch, :debug, "Middleware BEFORE" | |
end | |
def after | |
applog @watch, :debug, "Middleware AFTER" | |
end | |
def valid? | |
applog @watch, :debug, "Middleware Valid" | |
super | |
end | |
def test | |
if middleware_up? | |
applog watch, :info, "Middleware Up" | |
true | |
else | |
false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment