-
Notifications
You must be signed in to change notification settings - Fork 0
Debbuging in Docker
On the docker-compose.yaml file, we have to set, on the python server cyberpython, the number of workers to be 1 (--workers) in the gunicorn command also we have to set the numbers of replicas from 2 to 1. 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 and the number of replicas from 1 to 2.
After you do all the setup, you have to run the debug config from vscode when you start your docker and you access the app from browser. Even though you don't any breakpoints it's a must, otherwise it hangs.