Skip to content

Commit 2ac5fb9

Browse files
authored
Update vs_code_django_unit_test_debugging_notes.md with instructions for debugging the worker container
1 parent a0c0f97 commit 2ac5fb9

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

sphinx/misc/vs_code_django_unit_test_debugging_notes.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,65 @@ For the non-container instance of vscode, the debugger is used at runtime with t
120120
}
121121
```
122122

123+
### Get the VS Code debugger to work with the celery container
124+
125+
Add the worker debugger config to the .vscode/launch.json file
126+
```json
127+
{
128+
"version": "0.2.0",
129+
"configurations": [
130+
{
131+
"name": "Run Django",
132+
"type": "python",
133+
"request": "attach",
134+
"pathMappings": [
135+
{
136+
"localRoot": "${workspaceFolder}/specifyweb",
137+
"remoteRoot": "/opt/specify7/specifyweb"
138+
}
139+
],
140+
"port": 3000,
141+
"host": "127.0.0.1",
142+
},
143+
{
144+
"name": "Run Worker",
145+
"type": "python",
146+
"request": "attach",
147+
"pathMappings": [
148+
{
149+
"localRoot": "${workspaceFolder}/specifyweb",
150+
"remoteRoot": "/opt/specify7/specifyweb"
151+
}
152+
],
153+
"port": 3001,
154+
"host": "127.0.0.1",
155+
}
156+
]
157+
}
158+
```
159+
160+
Edit the command in the celery worker container config in the docker-compose.yml file
161+
```yaml
162+
specify7-worker:
163+
build:
164+
context: ./.
165+
target: run-development
166+
command: bash -c "ve/bin/python -m debugpy --listen 0.0.0.0:3001 --wait-for-client -m celery -A specifyweb worker -l INFO --concurrency=1 -Q $DATABASE_NAME"
167+
init: true
168+
volumes:
169+
- "./config:/opt/Specify/config:ro"
170+
- "static-files:/volumes/static-files"
171+
- "./specifyweb:/opt/specify7/specifyweb"
172+
extra_hosts:
173+
- "host.docker.internal:host-gateway"
174+
env_file: .env
175+
```
176+
177+
Run `docker compose up --build`
178+
179+
Reload the vscode window
180+
181+
In the VS Code debugger panel, next to "Run and Debug", select the picklist and select "Run Worker", and press the play button.
182+
183+
The breakpoints you set should now be caught!
123184

0 commit comments

Comments
 (0)