Skip to content

Commit a73ef8b

Browse files
committed
Merge branch 'main' of github.com:specify/specify.github.io
2 parents 093b385 + 51bbd8b commit a73ef8b

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

sphinx/misc/vs_code_django_unit_test_debugging_notes.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,69 @@ 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 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+
ports:
176+
- "3001:3001" # for debugging celery worker
177+
```
178+
179+
Run `docker compose up --build`
180+
181+
Reload the vscode window (might not need to do)
182+
183+
In the VS Code debugger panel, next to "Run and Debug", select the picklist and select "Run Worker", and press the play button.
184+
185+
The breakpoints you set should now be caught!
186+
187+
Remember that the code in the celery worker container doens't automatically get update, so need to do 'docker compose down' and 'docker compose up' after code changes before you can start debugging again.
123188

0 commit comments

Comments
 (0)