Skip to content

Latest commit

 

History

History
80 lines (50 loc) · 2.16 KB

debugger.md

File metadata and controls

80 lines (50 loc) · 2.16 KB

/ Menu / Tasks / Debugger

Task: Debugger

This section will instruct you on how to attach a debugger to your container.
No need to start an entirely new server or environment, just use the already running container 😃

You should probably make a View before doing this in order to have something to debug.

NOTE:

  1. The docker-compose config and VSCode are already configured to expect a process on port 5678.
  2. Because of hot-reload, the debugger process will be shutdown whenever there are changes in the container. You must start re-attach VSCode to continue debugging the "new" code.


Table of contents:



Step 1: Install debugger

Install debugpy inside the virtual environment of container clean.

Solution

From root of project on host machine:

docker compose exec clean pipenv install debugpy


Step 2: Initialize debugger

Attach a debugger to the django server. Use host 0.0.0.0 with port 5678. Initialize inside the file clean/root/wsgi.py.

Solution

See debugpy.py and wsgi.py in solution.



Step 3: Start VSCode debug session

Go to the debug tab in VSCode in the left sidebar. At the top you can select which configuration you want to use (see launch.json). Select the one for clean, the editor should now be orange.

If you some other editor than VSCode, you must configure it yourself. The process is running as mentioned on port 5678, so in theory anything can listen to it.



Step 4: Set breakpoint

Set a breakpoint 🔴 on a line of code you want to inspect. Preferably inside a View so that you can trigger a request to that endpoint.



👈 Back to Tasks