Skip to content

Commit

Permalink
implemented ability to specify shell command that will be called in c…
Browse files Browse the repository at this point in the history
…ase a health check fails. This can be used to implement self-healing behaviour.
  • Loading branch information
Frederik Fix committed Dec 1, 2009
1 parent 70f607b commit 693dcbb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions doord/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,33 @@ def load_config(self, options):
def report_health(self):
health = self.reader.report_health()
if health != True:
return "%s: %s" % (self.reader, health)
log_message = "%s: %s" % (self.reader, health)
self.call_health_check_failback(self.reader, log_message)
return log_message

if self.authenticator:
health = self.authenticator.report_health()
if health != True:
return "%s: %s" % (self.authenticator, health)
log_message = "%s: %s" % (self.authenticator, health)
self.call_health_check_failback(self.authenticator, log_message)
return log_message

health = self.reader.report_health()
health = self.actuator.report_health()
if health != True:
return "%s: %s" % (self.reader, health)
log_message = "%s: %s" % (self.actuator, health)
self.call_health_check_failback(self.actuator, log_message)
return log_message

return True

def check_health(self):
return defer.succeed(True)

def call_health_check_failback(self, object, health):
command = object.get_config("health_check_failback", None)
if command:
subprocess.Popen(command, shell=True, env={ log_message: health })

# app logic
def handle_input(self, token):
"""this is called by the Reader class when a card has been swiped"""
Expand Down

0 comments on commit 693dcbb

Please sign in to comment.