From 75738efc0d36bbf5805b3463d618dbffa7fe5bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 23 May 2016 15:17:16 +0200 Subject: [PATCH] Added "runserver_profile" management command. --- .gitignore | 1 + pillar/manage.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d3391cbf..7fb098fa 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ /.coverage /pillar/pillar.egg-info/ /pillar/google_app.json +profile.stats diff --git a/pillar/manage.py b/pillar/manage.py index 5944764e..194f646b 100755 --- a/pillar/manage.py +++ b/pillar/manage.py @@ -39,14 +39,15 @@ MONGO_HOST = os.environ.get('MONGO_HOST', 'localhost') @manager.command -def runserver(): +def runserver(**options): # Automatic creation of STORAGE_DIR path if it's missing if not os.path.exists(app.config['STORAGE_DIR']): os.makedirs(app.config['STORAGE_DIR']) app.run(host=app.config['HOST'], port=app.config['PORT'], - debug=app.config['DEBUG']) + debug=app.config['DEBUG'], + **options) @manager.command @@ -60,6 +61,13 @@ def runserver_memlimit(limit_kb=1000000): runserver() +@manager.command +def runserver_profile(pfile='profile.stats'): + import cProfile + + cProfile.run('runserver(use_reloader=False)', pfile) + + def post_item(entry, data): return post_internal(entry, data)