diff options
-rw-r--r-- | healthcheck.py | 16 |
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: |