-
Notifications
You must be signed in to change notification settings - Fork 0
Debbuging in Docker
cybersecuritylearning edited this page Nov 4, 2023
·
11 revisions
On the docker-compose file, we have to set, on the python server cyberpython, the number of workers to be 1 (--workers) in the gunicorn command. We have to expose a port from the same image, like 9001:9001.
We have to add some code on the /src/server/wsgi.py file.
import debugpy
debugpy.listen(('0.0.0.0', 9001))
debugpy.wait_for_client()
print("connected")
We have to add an entry in the launch.json file like follows:
{
"name": "Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "0.0.0.0",
"port": 9001
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/src/server",
"remoteRoot": "."
}
],
"justMyCode": true
},
Now, you can go to script files and put your breakpoints like normal and run the Remote Attach playbook from the debug section of VSCode.
When you deploy your app, comment all the code from the debbuging part and from the docker-compose and put again 16 workers at gunicorn.