|
| 1 | +# LMS Debug Mode Setup |
| 2 | + |
| 3 | +This document describes how to run the LMS service in normal or debug mode using the Devstack Makefile. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +### Normal Mode (Default) |
| 8 | +To run the LMS service in normal mode without debugpy: |
| 9 | +```bash |
| 10 | +make dev.up.lms |
| 11 | +``` |
| 12 | + |
| 13 | +### Debug Mode with debugpy |
| 14 | +To run the LMS service in debug mode with debugpy enabled: |
| 15 | +```bash |
| 16 | +make dev.debug.lms |
| 17 | +``` |
| 18 | + |
| 19 | +## How It Works |
| 20 | + |
| 21 | +### Implementation Details |
| 22 | + |
| 23 | +1. **LMS Runner Script** (`lms-run.sh`) |
| 24 | + - A bash script that determines whether to run in normal or debug mode |
| 25 | + - Checks the `DEVSTACK_DEBUG` environment variable |
| 26 | + - If set to `debug`: Installs and runs with debugpy on port 44568 |
| 27 | + - If set to `normal` (default): Runs without debugpy |
| 28 | + |
| 29 | +2. **Docker Compose Configuration** |
| 30 | + - The LMS service command now calls `lms-run.sh` instead of hardcoding debugpy |
| 31 | + - The `DEVSTACK_DEBUG` environment variable is passed to the container |
| 32 | + - Port 44568 remains exposed in docker-compose.yml for debugpy |
| 33 | + |
| 34 | +3. **Makefile Targets** |
| 35 | + - `dev.up.%`: Standard targets for normal mode (unchanged) |
| 36 | + - `dev.debug.%`: New targets that set `DEVSTACK_DEBUG=debug` before starting services |
| 37 | + - Examples: |
| 38 | + - `make dev.up.lms` - Start LMS normally |
| 39 | + - `make dev.debug.lms` - Start LMS with debugpy |
| 40 | + - `make dev.debug.lms+discovery` - Start LMS with debugpy and discovery in normal mode |
| 41 | + |
| 42 | +## VS Code Debugging |
| 43 | + |
| 44 | +With the LMS running in debug mode, you can attach VS Code debugger: |
| 45 | + |
| 46 | +1. Ensure `make dev.debug.lms` is running |
| 47 | +2. In VS Code, go to the Debug view (Ctrl+Shift+D) |
| 48 | +3. Select "LMS Debugpy" configuration |
| 49 | +4. Click the play button to attach the debugger |
| 50 | + |
| 51 | +The debugger will wait for client attachment when configured with `--wait-for-client` flag. |
| 52 | + |
| 53 | +## Switching Between Modes |
| 54 | + |
| 55 | +To switch from one mode to another: |
| 56 | + |
| 57 | +```bash |
| 58 | +# Kill existing LMS container |
| 59 | +docker-compose kill lms |
| 60 | + |
| 61 | +# Start in the desired mode |
| 62 | +make dev.up.lms # Normal |
| 63 | +# or |
| 64 | +make dev.debug.lms # Debug with debugpy |
| 65 | +``` |
| 66 | + |
| 67 | +## Troubleshooting |
| 68 | + |
| 69 | +- **Debugpy port already in use**: Ensure no other process is using port 44568 |
| 70 | +- **Script permission issues**: The `lms-run.sh` script will be executed inside the container, so host permissions don't matter |
| 71 | +- **Environment variable not passed**: Verify using `docker-compose exec lms env | grep DEVSTACK_DEBUG` |
| 72 | + |
| 73 | +## Technical Notes |
| 74 | + |
| 75 | +- The `DEVSTACK_DEBUG` environment variable only affects LMS service |
| 76 | +- Other services (cms, lms-worker, etc.) are not affected by this flag |
| 77 | +- For services other than LMS, standard `dev.up` and `dev.debug` targets still apply the environment variable, but it won't affect their behavior unless they also implement similar logic |
0 commit comments