如何在gunicorn上运行时使用python的cProfile来配置django应用程序

Ram*_*ir. 5 python django profiler cprofile gunicorn

如何在使用python cProfile在gunicorn上运行时分析Django应用程序.

我可以在开发模式下进行分析: python -m cProfile -o sample.profile manage.py runserver

但是当它使用gunicorn在生产服务器上运行时我该怎么办?

Ano*_*ous 5

您可以使用gunicorn 以这种方式运行它。

$ DJANGO_SETTINGS_MODULE=myapp.settings python -m cProfile -o output_file ../env/bin/gunicorn --workers=8 --bind 127.0.0.1:8000 myapp.wsgi:application 
Run Code Online (Sandbox Code Playgroud)