From 0473afe2dbbcbeda897e8797ea62d0e2a79c5a86 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Sun, 3 Nov 2013 12:32:38 +0100 Subject: [PATCH] add profiling option to server configuration --- docs/CONFIGURATION.rst | 7 ++++++- isso/__init__.py | 6 +++++- isso/core.py | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/CONFIGURATION.rst b/docs/CONFIGURATION.rst index e531220..1657f43 100644 --- a/docs/CONFIGURATION.rst +++ b/docs/CONFIGURATION.rst @@ -91,7 +91,7 @@ purge-after Server ------ -HTTP server configuration, does **not** apply to uWSGI. +HTTP server configuration, does **not** apply to uWSGI (except for `profile`). .. code-block:: ini @@ -99,6 +99,7 @@ HTTP server configuration, does **not** apply to uWSGI. host = localhost port = 8080 reload = off + profile = off host listen on specified interface @@ -110,6 +111,10 @@ reload reload application, when the source code has changed. Useful for development (don't forget to use a fixed `session-key`). +profile + show 10 most time consuming function in Isso after each request. Do + not use in production. + SMTP ---- diff --git a/isso/__init__.py b/isso/__init__.py index 229797d..1ef59fc 100644 --- a/isso/__init__.py +++ b/isso/__init__.py @@ -162,7 +162,11 @@ def make_app(conf=None): else: logger.warn("unable to connect to HTTP server") - app = ProxyFix(wsgi.SubURI(SharedDataMiddleware(isso.wsgi_app, { + if isso.conf.getboolean("server", "profile"): + from werkzeug.contrib.profiler import ProfilerMiddleware + isso = ProfilerMiddleware(isso, sort_by=("cumtime", ), restrictions=("isso/(?!lib)", )) + + app = ProxyFix(wsgi.SubURI(SharedDataMiddleware(isso, { '/js': join(dirname(__file__), 'js/'), '/css': join(dirname(__file__), 'css/') }))) diff --git a/isso/core.py b/isso/core.py index 4638e25..92eb666 100644 --- a/isso/core.py +++ b/isso/core.py @@ -92,7 +92,8 @@ class Config: "enabled = false", "purge-after = 30d", "[server]", - "host = localhost", "port = 8080", "reload = off", + "host = localhost", "port = 8080", + "reload = off", "profile = off", "[smtp]", "username = ", "password = ", "host = localhost", "port = 465", "ssl = on",