Include git revision IDs in /health response.

This commit is contained in:
Neil Williams
2012-03-28 14:03:41 -07:00
parent cae85cf548
commit 057dfc99cd
2 changed files with 7 additions and 4 deletions

View File

@@ -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)

View File

@@ -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" %