Skip to content

Commit 3f2f7b7

Browse files
[developer productivity improvement] Running awx components in vscode debugger (#14942)
Enable VSCode debugger integration when attaching VSCode to with AWX docker-compose development environment container - add debugpy launch target in `.vscode/launch.json` to enable launching awx processes with debugpy - add vscode tasks in `.vscode/tasks.json` to facilitate shutting down corresponding supervisord managed processes while launching process with debugpy - modify nginx conf to add django runserver as fallback to uwsgi (enable launching API server via debugpy)
1 parent b71645f commit 3f2f7b7

File tree

6 files changed

+233
-2
lines changed

6 files changed

+233
-2
lines changed

.vscode/launch.json

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "run_ws_heartbeat",
6+
"type": "debugpy",
7+
"request": "launch",
8+
"program": "manage.py",
9+
"args": ["run_ws_heartbeat"],
10+
"django": true,
11+
"preLaunchTask": "stop awx-ws-heartbeat",
12+
"postDebugTask": "start awx-ws-heartbeat"
13+
},
14+
{
15+
"name": "run_cache_clear",
16+
"type": "debugpy",
17+
"request": "launch",
18+
"program": "manage.py",
19+
"args": ["run_cache_clear"],
20+
"django": true,
21+
"preLaunchTask": "stop awx-cache-clear",
22+
"postDebugTask": "start awx-cache-clear"
23+
},
24+
{
25+
"name": "run_callback_receiver",
26+
"type": "debugpy",
27+
"request": "launch",
28+
"program": "manage.py",
29+
"args": ["run_callback_receiver"],
30+
"django": true,
31+
"preLaunchTask": "stop awx-receiver",
32+
"postDebugTask": "start awx-receiver"
33+
},
34+
{
35+
"name": "run_dispatcher",
36+
"type": "debugpy",
37+
"request": "launch",
38+
"program": "manage.py",
39+
"args": ["run_dispatcher"],
40+
"django": true,
41+
"preLaunchTask": "stop awx-dispatcher",
42+
"postDebugTask": "start awx-dispatcher"
43+
},
44+
{
45+
"name": "run_rsyslog_configurer",
46+
"type": "debugpy",
47+
"request": "launch",
48+
"program": "manage.py",
49+
"args": ["run_rsyslog_configurer"],
50+
"django": true,
51+
"preLaunchTask": "stop awx-rsyslog-configurer",
52+
"postDebugTask": "start awx-rsyslog-configurer"
53+
},
54+
{
55+
"name": "run_cache_clear",
56+
"type": "debugpy",
57+
"request": "launch",
58+
"program": "manage.py",
59+
"args": ["run_cache_clear"],
60+
"django": true,
61+
"preLaunchTask": "stop awx-cache-clear",
62+
"postDebugTask": "start awx-cache-clear"
63+
},
64+
{
65+
"name": "run_wsrelay",
66+
"type": "debugpy",
67+
"request": "launch",
68+
"program": "manage.py",
69+
"args": ["run_wsrelay"],
70+
"django": true,
71+
"preLaunchTask": "stop awx-wsrelay",
72+
"postDebugTask": "start awx-wsrelay"
73+
},
74+
{
75+
"name": "daphne",
76+
"type": "debugpy",
77+
"request": "launch",
78+
"program": "/var/lib/awx/venv/awx/bin/daphne",
79+
"args": ["-b", "127.0.0.1", "-p", "8051", "awx.asgi:channel_layer"],
80+
"django": true,
81+
"preLaunchTask": "stop awx-daphne",
82+
"postDebugTask": "start awx-daphne"
83+
},
84+
{
85+
"name": "runserver(uwsgi alternative)",
86+
"type": "debugpy",
87+
"request": "launch",
88+
"program": "manage.py",
89+
"args": ["runserver", "127.0.0.1:8052"],
90+
"django": true,
91+
"preLaunchTask": "stop awx-uwsgi",
92+
"postDebugTask": "start awx-uwsgi"
93+
},
94+
{
95+
"name": "runserver_plus(uwsgi alternative)",
96+
"type": "debugpy",
97+
"request": "launch",
98+
"program": "manage.py",
99+
"args": ["runserver_plus", "127.0.0.1:8052"],
100+
"django": true,
101+
"preLaunchTask": "stop awx-uwsgi and install Werkzeug",
102+
"postDebugTask": "start awx-uwsgi"
103+
},
104+
{
105+
"name": "shell_plus",
106+
"type": "debugpy",
107+
"request": "launch",
108+
"program": "manage.py",
109+
"args": ["shell_plus"],
110+
"django": true,
111+
},
112+
]
113+
}

.vscode/tasks.json

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "start awx-cache-clear",
6+
"type": "shell",
7+
"command": "supervisorctl start tower-processes:awx-cache-clear"
8+
},
9+
{
10+
"label": "stop awx-cache-clear",
11+
"type": "shell",
12+
"command": "supervisorctl stop tower-processes:awx-cache-clear"
13+
},
14+
{
15+
"label": "start awx-daphne",
16+
"type": "shell",
17+
"command": "supervisorctl start tower-processes:awx-daphne"
18+
},
19+
{
20+
"label": "stop awx-daphne",
21+
"type": "shell",
22+
"command": "supervisorctl stop tower-processes:awx-daphne"
23+
},
24+
{
25+
"label": "start awx-dispatcher",
26+
"type": "shell",
27+
"command": "supervisorctl start tower-processes:awx-dispatcher"
28+
},
29+
{
30+
"label": "stop awx-dispatcher",
31+
"type": "shell",
32+
"command": "supervisorctl stop tower-processes:awx-dispatcher"
33+
},
34+
{
35+
"label": "start awx-receiver",
36+
"type": "shell",
37+
"command": "supervisorctl start tower-processes:awx-receiver"
38+
},
39+
{
40+
"label": "stop awx-receiver",
41+
"type": "shell",
42+
"command": "supervisorctl stop tower-processes:awx-receiver"
43+
},
44+
{
45+
"label": "start awx-rsyslog-configurer",
46+
"type": "shell",
47+
"command": "supervisorctl start tower-processes:awx-rsyslog-configurer"
48+
},
49+
{
50+
"label": "stop awx-rsyslog-configurer",
51+
"type": "shell",
52+
"command": "supervisorctl stop tower-processes:awx-rsyslog-configurer"
53+
},
54+
{
55+
"label": "start awx-rsyslogd",
56+
"type": "shell",
57+
"command": "supervisorctl start tower-processes:awx-rsyslogd"
58+
},
59+
{
60+
"label": "stop awx-rsyslogd",
61+
"type": "shell",
62+
"command": "supervisorctl stop tower-processes:awx-rsyslogd"
63+
},
64+
{
65+
"label": "start awx-uwsgi",
66+
"type": "shell",
67+
"command": "supervisorctl start tower-processes:awx-uwsgi"
68+
},
69+
{
70+
"label": "stop awx-uwsgi",
71+
"type": "shell",
72+
"command": "supervisorctl stop tower-processes:awx-uwsgi"
73+
},
74+
{
75+
"label": "stop awx-uwsgi and install Werkzeug",
76+
"type": "shell",
77+
"command": "pip install Werkzeug; supervisorctl stop tower-processes:awx-uwsgi"
78+
},
79+
{
80+
"label": "start awx-ws-heartbeat",
81+
"type": "shell",
82+
"command": "supervisorctl start tower-processes:awx-ws-heartbeat"
83+
},
84+
{
85+
"label": "stop awx-ws-heartbeat",
86+
"type": "shell",
87+
"command": "supervisorctl stop tower-processes:awx-ws-heartbeat"
88+
},
89+
{
90+
"label": "start awx-wsrelay",
91+
"type": "shell",
92+
"command": "supervisorctl start tower-processes:awx-wsrelay"
93+
},
94+
{
95+
"label": "stop awx-wsrelay",
96+
"type": "shell",
97+
"command": "supervisorctl stop tower-processes:awx-wsrelay"
98+
}
99+
]
100+
}

awx/settings/development.py

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
# Allows user to trigger task managers directly for debugging and profiling purposes.
7373
# Only works in combination with settings.SETTINGS_MODULE == 'awx.settings.development'
7474
AWX_DISABLE_TASK_MANAGERS = False
75+
76+
# Needed for launching runserver in debug mode
77+
CSRF_TRUSTED_ORIGINS = ["https://localhost:8043"]
7578
# ======================!!!!!!! FOR DEVELOPMENT ONLY !!!!!!!=================================
7679

7780
# Store a snapshot of default settings at this point before loading any

requirements/requirements_dev.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ jupyter
2020
# matplotlib - Caused issues when bumping to setuptools 58
2121
backports.tempfile # support in unit tests for py32+ tempfile.TemporaryDirectory
2222
git+https://github.com/artefactual-labs/mockldap.git@master#egg=mockldap
23-
sdb
24-
remote-pdb
2523
gprof2dot
2624
atomicwrites==1.4.0
2725
flake8
2826
yamllint
2927
pip>=21.3 # PEP 660 – Editable installs for pyproject.toml based builds (wheel based)
28+
29+
# python debuggers
30+
debugpy
31+
remote-pdb
32+
sdb

tools/docker-compose/ansible/roles/sources/templates/nginx.conf.j2

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ http {
2929
server localhost:8050;
3030
}
3131

32+
upstream runserver {
33+
server localhost:8052;
34+
}
35+
3236
upstream daphne {
3337
server localhost:8051;
3438
}

tools/docker-compose/ansible/roles/sources/templates/nginx.locations.conf.j2

+8
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@ location {{ ingress_path }} {
3838
uwsgi_read_timeout 120s;
3939
uwsgi_pass uwsgi;
4040
include /etc/nginx/uwsgi_params;
41+
error_page 502 = @fallback;
42+
}
43+
44+
# Enable scenario where we shutdown uwsgi and launching runserver for debugging purposes
45+
location @fallback {
46+
# Add trailing / if missing
47+
rewrite ^(.*)$http_host(.*[^/])$ $1$http_host$2/ permanent;
48+
proxy_pass http://runserver;
4149
}

0 commit comments

Comments
 (0)