diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000000..62289122564a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,113 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "run_ws_heartbeat", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["run_ws_heartbeat"], + "django": true, + "preLaunchTask": "stop awx-ws-heartbeat", + "postDebugTask": "start awx-ws-heartbeat" + }, + { + "name": "run_cache_clear", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["run_cache_clear"], + "django": true, + "preLaunchTask": "stop awx-cache-clear", + "postDebugTask": "start awx-cache-clear" + }, + { + "name": "run_callback_receiver", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["run_callback_receiver"], + "django": true, + "preLaunchTask": "stop awx-receiver", + "postDebugTask": "start awx-receiver" + }, + { + "name": "run_dispatcher", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["run_dispatcher"], + "django": true, + "preLaunchTask": "stop awx-dispatcher", + "postDebugTask": "start awx-dispatcher" + }, + { + "name": "run_rsyslog_configurer", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["run_rsyslog_configurer"], + "django": true, + "preLaunchTask": "stop awx-rsyslog-configurer", + "postDebugTask": "start awx-rsyslog-configurer" + }, + { + "name": "run_cache_clear", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["run_cache_clear"], + "django": true, + "preLaunchTask": "stop awx-cache-clear", + "postDebugTask": "start awx-cache-clear" + }, + { + "name": "run_wsrelay", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["run_wsrelay"], + "django": true, + "preLaunchTask": "stop awx-wsrelay", + "postDebugTask": "start awx-wsrelay" + }, + { + "name": "daphne", + "type": "debugpy", + "request": "launch", + "program": "/var/lib/awx/venv/awx/bin/daphne", + "args": ["-b", "127.0.0.1", "-p", "8051", "awx.asgi:channel_layer"], + "django": true, + "preLaunchTask": "stop awx-daphne", + "postDebugTask": "start awx-daphne" + }, + { + "name": "runserver(uwsgi alternative)", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["runserver", "127.0.0.1:8052"], + "django": true, + "preLaunchTask": "stop awx-uwsgi", + "postDebugTask": "start awx-uwsgi" + }, + { + "name": "runserver_plus(uwsgi alternative)", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["runserver_plus", "127.0.0.1:8052"], + "django": true, + "preLaunchTask": "stop awx-uwsgi and install Werkzeug", + "postDebugTask": "start awx-uwsgi" + }, + { + "name": "shell_plus", + "type": "debugpy", + "request": "launch", + "program": "manage.py", + "args": ["shell_plus"], + "django": true, + }, + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000000..0b878663c311 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,100 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "start awx-cache-clear", + "type": "shell", + "command": "supervisorctl start tower-processes:awx-cache-clear" + }, + { + "label": "stop awx-cache-clear", + "type": "shell", + "command": "supervisorctl stop tower-processes:awx-cache-clear" + }, + { + "label": "start awx-daphne", + "type": "shell", + "command": "supervisorctl start tower-processes:awx-daphne" + }, + { + "label": "stop awx-daphne", + "type": "shell", + "command": "supervisorctl stop tower-processes:awx-daphne" + }, + { + "label": "start awx-dispatcher", + "type": "shell", + "command": "supervisorctl start tower-processes:awx-dispatcher" + }, + { + "label": "stop awx-dispatcher", + "type": "shell", + "command": "supervisorctl stop tower-processes:awx-dispatcher" + }, + { + "label": "start awx-receiver", + "type": "shell", + "command": "supervisorctl start tower-processes:awx-receiver" + }, + { + "label": "stop awx-receiver", + "type": "shell", + "command": "supervisorctl stop tower-processes:awx-receiver" + }, + { + "label": "start awx-rsyslog-configurer", + "type": "shell", + "command": "supervisorctl start tower-processes:awx-rsyslog-configurer" + }, + { + "label": "stop awx-rsyslog-configurer", + "type": "shell", + "command": "supervisorctl stop tower-processes:awx-rsyslog-configurer" + }, + { + "label": "start awx-rsyslogd", + "type": "shell", + "command": "supervisorctl start tower-processes:awx-rsyslogd" + }, + { + "label": "stop awx-rsyslogd", + "type": "shell", + "command": "supervisorctl stop tower-processes:awx-rsyslogd" + }, + { + "label": "start awx-uwsgi", + "type": "shell", + "command": "supervisorctl start tower-processes:awx-uwsgi" + }, + { + "label": "stop awx-uwsgi", + "type": "shell", + "command": "supervisorctl stop tower-processes:awx-uwsgi" + }, + { + "label": "stop awx-uwsgi and install Werkzeug", + "type": "shell", + "command": "pip install Werkzeug; supervisorctl stop tower-processes:awx-uwsgi" + }, + { + "label": "start awx-ws-heartbeat", + "type": "shell", + "command": "supervisorctl start tower-processes:awx-ws-heartbeat" + }, + { + "label": "stop awx-ws-heartbeat", + "type": "shell", + "command": "supervisorctl stop tower-processes:awx-ws-heartbeat" + }, + { + "label": "start awx-wsrelay", + "type": "shell", + "command": "supervisorctl start tower-processes:awx-wsrelay" + }, + { + "label": "stop awx-wsrelay", + "type": "shell", + "command": "supervisorctl stop tower-processes:awx-wsrelay" + } + ] +} diff --git a/awx/settings/development.py b/awx/settings/development.py index bdf882c795b5..e518c1204f78 100644 --- a/awx/settings/development.py +++ b/awx/settings/development.py @@ -72,6 +72,9 @@ # Allows user to trigger task managers directly for debugging and profiling purposes. # Only works in combination with settings.SETTINGS_MODULE == 'awx.settings.development' AWX_DISABLE_TASK_MANAGERS = False + +# Needed for launching runserver in debug mode +CSRF_TRUSTED_ORIGINS = ["https://localhost:8043"] # ======================!!!!!!! FOR DEVELOPMENT ONLY !!!!!!!================================= # Store a snapshot of default settings at this point before loading any diff --git a/requirements/requirements_dev.txt b/requirements/requirements_dev.txt index b5084695b9ab..4d087803fda0 100644 --- a/requirements/requirements_dev.txt +++ b/requirements/requirements_dev.txt @@ -20,10 +20,13 @@ jupyter # matplotlib - Caused issues when bumping to setuptools 58 backports.tempfile # support in unit tests for py32+ tempfile.TemporaryDirectory git+https://github.com/artefactual-labs/mockldap.git@master#egg=mockldap -sdb -remote-pdb gprof2dot atomicwrites==1.4.0 flake8 yamllint pip>=21.3 # PEP 660 – Editable installs for pyproject.toml based builds (wheel based) + +# python debuggers +debugpy +remote-pdb +sdb diff --git a/tools/docker-compose/ansible/roles/sources/templates/nginx.conf.j2 b/tools/docker-compose/ansible/roles/sources/templates/nginx.conf.j2 index 7115e155823b..e0be1528181d 100644 --- a/tools/docker-compose/ansible/roles/sources/templates/nginx.conf.j2 +++ b/tools/docker-compose/ansible/roles/sources/templates/nginx.conf.j2 @@ -29,6 +29,10 @@ http { server localhost:8050; } + upstream runserver { + server localhost:8052; + } + upstream daphne { server localhost:8051; } diff --git a/tools/docker-compose/ansible/roles/sources/templates/nginx.locations.conf.j2 b/tools/docker-compose/ansible/roles/sources/templates/nginx.locations.conf.j2 index fd2b89a69133..404be4ade26b 100644 --- a/tools/docker-compose/ansible/roles/sources/templates/nginx.locations.conf.j2 +++ b/tools/docker-compose/ansible/roles/sources/templates/nginx.locations.conf.j2 @@ -38,4 +38,12 @@ location {{ ingress_path }} { uwsgi_read_timeout 120s; uwsgi_pass uwsgi; include /etc/nginx/uwsgi_params; + error_page 502 = @fallback; +} + +# Enable scenario where we shutdown uwsgi and launching runserver for debugging purposes +location @fallback { + # Add trailing / if missing + rewrite ^(.*)$http_host(.*[^/])$ $1$http_host$2/ permanent; + proxy_pass http://runserver; }