summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Colmer <philip.colmer@linaro.org>2014-01-23 13:59:46 +0000
committerPhilip Colmer <philip.colmer@linaro.org>2014-01-23 13:59:46 +0000
commit2e113fe086898df91a1d7c479faa625cf72056a3 (patch)
treeeca4f662638ca4b24252cca8bdb5455bd1643770
parent22ff7739ef08261dae2ef189bcd72c1d1b666206 (diff)
downloadlinaro-healthcheck-2e113fe086898df91a1d7c479faa625cf72056a3.tar.gz
Added check for file saying that state change script is still running.
Fixed HTML output from script.
-rw-r--r--healthcheck.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/healthcheck.py b/healthcheck.py
index 8cd7a2c..856a8b2 100644
--- a/healthcheck.py
+++ b/healthcheck.py
@@ -17,6 +17,7 @@ class HealthCheck(object):
self.last_address = prev_addr
self.state_process = None
self.startingup_countdown = 0
+ self.logged_message = ""
def silentremove(self, filename):
try:
@@ -26,6 +27,7 @@ class HealthCheck(object):
raise
def logmsg(self, string):
+ self.logged_message = string
log.error(string, context='HTTP', severity=20, traceback=True)
@cherrypy.expose
@@ -53,7 +55,10 @@ class HealthCheck(object):
if (service_ip != self.last_address):
self.logmsg("Service IP = %s, last service IP = %s, this IP = %s" % (service_ip, self.last_address, self.system_ip))
- if (os.path.isfile(self.script_directory + "/frozen")):
+ if (os.path.isfile(self.script_directory + "/state-change-happening")):
+ self.logmsg("State change script is still executing ...")
+ new_state = self.last_state
+ elif (os.path.isfile(self.script_directory + "/frozen")):
if (self.last_state != States.Frozen):
self.logmsg("Frozen file exists")
new_state = States.Frozen
@@ -175,7 +180,6 @@ class HealthCheck(object):
cherrypy.response.status = new_response
cherrypy.response.headers['Content-type'] = 'text/html'
- cherrypy.response.body = ["<p>This is the Linaro health check service. State is %s and response code is %s</P>" % (str(new_state), str(new_response))]
# Save away the various bits of information
try:
@@ -253,6 +257,14 @@ class HealthCheck(object):
self.last_response = new_response
self.last_address = service_ip
+ body1 = "<P>This is the Linaro health check service. State is %s and response code is %s</P>" % (str(new_state), str(new_response))
+ if (self.logged_message == ""):
+ body2=""
+ else:
+ body2="<P>Most recent log message: %s</P>" % self.logged_message
+
+ return "%s%s" % (body1, body2)
+
def safereadline(logger, script_directory, filename):
line = ""
try: