mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 07:19:25 -05:00
Include git revision IDs in /health response.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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" %
|
||||
|
||||
Reference in New Issue
Block a user