From ef45362d591029cfdb2e74cf77017d810f69318a Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Thu, 22 Dec 2011 20:34:27 -0800 Subject: [PATCH] Remove other unused commands in HealthController. dump relies on the old paster setup, so it doesn't even work anymore. --- r2/r2/config/routing.py | 2 -- r2/r2/controllers/health.py | 53 ------------------------------------- 2 files changed, 55 deletions(-) diff --git a/r2/r2/config/routing.py b/r2/r2/config/routing.py index 75e7c82e1..337e869e8 100644 --- a/r2/r2/config/routing.py +++ b/r2/r2/config/routing.py @@ -146,8 +146,6 @@ def make_map(global_conf={}, app_conf={}): sort = "") mc('/health', controller='health', action='health') - mc('/health/:action', controller='health', - requirements=dict(action="threads|dump|sleep")) mc('/', controller='hot', action='listing') diff --git a/r2/r2/controllers/health.py b/r2/r2/controllers/health.py index 6da3ca9b5..62a8b4820 100644 --- a/r2/r2/controllers/health.py +++ b/r2/r2/controllers/health.py @@ -24,56 +24,3 @@ class HealthController(MinimalController): c.dontcache = True response.headers['Content-Type'] = 'text/plain' return "i'm still alive!" - - @validate(secret=nop('secret')) - def GET_sleep(self, secret): - if not g.shutdown_secret: - self.abort404() - if not secret or secret != g.shutdown_secret: - self.abort403() - - from time import sleep - seconds = int(request.GET.get('time', 60)) - seconds = min(seconds, 300) - sleep(seconds) - response.headers['Content-Type'] = 'text/plain' - return "slept" - - @validate(secret=nop('secret')) - def GET_dump(self, secret): - import sys, traceback, threading - - if not g.shutdown_secret: - self.abort404() - if not secret or secret != g.shutdown_secret: - self.abort403() - - thread_pool = c.thread_pool - - this_thread = threading.current_thread().ident - - idle = thread_pool.idle_workers - busy = [] - - for thread in thread_pool.workers: - if thread.ident not in idle: - busy.append(thread.ident) - - output = '' - for thread_id, stack in sys._current_frames().items(): - if thread_id == this_thread: - continue - if thread_id not in busy: - continue - output += '%s\n' % thread_id - tb = traceback.extract_stack(stack) - - for i, (filename, lineno, fnname, line) in enumerate(tb): - output += (' %(filename)s(%(lineno)d): %(fnname)s\n' - % dict(filename=filename, lineno=lineno, fnname=fnname)) - output += (' %(line)s\n' % dict(line=line)) - - output += "\n" - - response.headers['Content-Type'] = 'text/plain' - return output or 'no busy threads'