mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 15:58:06 -05:00
Remove paste-specific shutdown code for uWSGI.
This commit is contained in:
@@ -20,60 +20,15 @@ class HealthController(MinimalController):
|
||||
def pre(self):
|
||||
pass
|
||||
|
||||
def shutdown(self):
|
||||
thread_pool = c.thread_pool
|
||||
def _shutdown():
|
||||
#give busy threads 30 seconds to finish up
|
||||
for s in xrange(30):
|
||||
busy = thread_pool.track_threads()['busy']
|
||||
if not busy:
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
thread_pool.shutdown()
|
||||
worker.join()
|
||||
os._exit(3)
|
||||
|
||||
t = Thread(target = _shutdown)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
|
||||
def GET_health(self):
|
||||
c.dontcache = True
|
||||
|
||||
if g.shutdown:
|
||||
if g.shutdown == 'init':
|
||||
self.shutdown()
|
||||
g.shutdown = 'shutdown'
|
||||
abort(503, 'service temporarily unavailable')
|
||||
else:
|
||||
response.headers['Content-Type'] = 'text/plain'
|
||||
return "i'm still alive!"
|
||||
|
||||
@validate(secret=nop('secret'))
|
||||
def GET_threads(self, secret):
|
||||
if not g.shutdown_secret:
|
||||
self.abort404()
|
||||
if not secret or secret != g.shutdown_secret:
|
||||
self.abort403()
|
||||
|
||||
c.dontcache = True
|
||||
|
||||
if g.shutdown:
|
||||
c.response.content = "not bothering to check, due to shutdown"
|
||||
else:
|
||||
thread_pool = c.thread_pool
|
||||
tt = thread_pool.track_threads()
|
||||
s = ''
|
||||
for k in ('idle', 'busy', 'hung', 'dying', 'zombie'):
|
||||
s += "%s=%s " % (k, len(tt[k]))
|
||||
|
||||
s += "\n"
|
||||
c.response.content = s
|
||||
|
||||
response.headers['Content-Type'] = 'text/plain'
|
||||
return c.response
|
||||
|
||||
@validate(secret=nop('secret'))
|
||||
def GET_sleep(self, secret):
|
||||
if not g.shutdown_secret:
|
||||
|
||||
@@ -96,8 +96,6 @@ class BaseController(WSGIController):
|
||||
request.environ['pylons.routes_dict']['action'] = \
|
||||
meth + '_' + action
|
||||
|
||||
c.thread_pool = environ['paste.httpserver.thread_pool']
|
||||
|
||||
c.response = Response()
|
||||
try:
|
||||
res = WSGIController.__call__(self, environ, start_response)
|
||||
|
||||
Reference in New Issue
Block a user