diff --git a/r2/r2/controllers/health.py b/r2/r2/controllers/health.py index 62a8b4820..08fead5c8 100644 --- a/r2/r2/controllers/health.py +++ b/r2/r2/controllers/health.py @@ -1,6 +1,7 @@ from threading import Thread import os import time +import json from pylons.controllers.util import abort from pylons import c, g, response @@ -23,4 +24,4 @@ class HealthController(MinimalController): def GET_health(self): c.dontcache = True response.headers['Content-Type'] = 'text/plain' - return "i'm still alive!" + return json.dumps(g.versions, sort_keys=True, indent=4) diff --git a/r2/r2/lib/app_globals.py b/r2/r2/lib/app_globals.py index 5dd0731ee..595187d5c 100755 --- a/r2/r2/lib/app_globals.py +++ b/r2/r2/lib/app_globals.py @@ -428,13 +428,15 @@ class Globals(object): raise Exception("write_query_queue requires use_query_cache") # try to set the source control revision number + self.versions = {} + try: - self.version = subprocess.check_output(["git", "rev-parse", "HEAD"]) + self.versions['r2'] = subprocess.check_output(["git", "rev-parse", "HEAD"]) except subprocess.CalledProcessError, e: self.log.info("Couldn't read source revision (%r)" % e) - self.version = self.short_version = '(unknown)' + self.versions['r2'] = self.short_version = '(unknown)' else: - self.short_version = self.version[:7] + self.short_version = self.versions['r2'][:7] if self.log_start: self.log.error("reddit app %s:%s started %s at %s" %