diff --git a/docker-compose.yml b/docker-compose.yml index 4b8148e4..a76c6873 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,6 +24,7 @@ services: - SAVEEYE=TRUE - PROJECT_NAME=LocalWEBAPI - LOG_PATH=/tmp/dongtai-agent-python.log + - CPROFILE=TRUE volumes: - .:/opt/dongtai/webapi/ diff --git a/requirements-prod.txt b/requirements-prod.txt index 4025cf29..dc3e08c0 100644 --- a/requirements-prod.txt +++ b/requirements-prod.txt @@ -24,6 +24,4 @@ xlwt==1.3.0 uwsgi==2.0.19.1 pyre2~=0.3.6 jq -ddt -faker https://huoqi-public.oss-cn-beijing.aliyuncs.com/iast/dongtai-latest.tar.gz diff --git a/requirements-test.txt b/requirements-test.txt index 3a614275..4a756476 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -27,3 +27,4 @@ https://huoqi-public.oss-cn-beijing.aliyuncs.com/iast/dongtai-test-latest.tar.gz ddt faker jq +django-cprofile-middleware diff --git a/webapi/settings.py b/webapi/settings.py index 4cea0bea..0079b871 100644 --- a/webapi/settings.py +++ b/webapi/settings.py @@ -373,6 +373,13 @@ def safe_execute(default, exception, function, *args): REST_FRAMEWORK[ 'DEFAULT_SCHEMA_CLASS'] = 'drf_spectacular.openapi.AutoSchema' + +if os.getenv('environment', None) == 'TEST' or os.getenv('CPROFILE', + None) == 'TRUE': + DJANGO_CPROFILE_MIDDLEWARE_REQUIRE_STAFF = False + MIDDLEWARE.append( + 'django_cprofile_middleware.middleware.ProfilerMiddleware') + SCA_BASE_URL = config.get('sca', 'base_url') if os.getenv('environment', None) in ('TEST', 'PROD'):