Remove paste-specific shutdown code for uWSGI.

This commit is contained in:
Neil Williams
2011-05-06 10:48:19 -07:00
parent 87a45f8bce
commit 90237bf998
2 changed files with 0 additions and 47 deletions

View File

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

View File

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