Skip to content

Commit c455481

Browse files
Debug support (#95)
* perf: debug support * chore: update submodules * perf: align start script to others * chore: update submodules
1 parent 453c76c commit c455481

File tree

5 files changed

+50
-5
lines changed

5 files changed

+50
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,5 @@ dmypy.json
129129
.pyre/
130130

131131
# VSCode
132-
.vscode
132+
.vscode/*
133+
!.vscode/launch.json

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python Debugger: refinery-updater",
9+
"type": "debugpy",
10+
"request": "attach",
11+
"connect": {
12+
"host": "localhost",
13+
"port": 15674
14+
},
15+
"pathMappings": [
16+
{
17+
"localRoot": "${workspaceFolder}",
18+
"remoteRoot": "."
19+
}
20+
]
21+
}
22+
]
23+
}

requirements-dev.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
-r requirements.txt
22
httpx==0.25.0
3-
pytest==8.1.1
3+
pytest==8.1.1
4+
debugpy==1.8.12

start

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
#!/bin/bash
2+
3+
DEBUG_MODE=false
4+
DEBUG_PORT=15674
5+
6+
while getopts d flag
7+
do
8+
case "${flag}" in
9+
d) DEBUG_MODE=true;;
10+
esac
11+
done
12+
13+
CMD=""
14+
if [ $DEBUG_MODE = true ]; then
15+
CMD="debugpy --wait-for-client --listen 0.0.0.0:$DEBUG_PORT -m uvicorn app:app --host 0.0.0.0 --port 80 --reload"
16+
fi
17+
218
trap "echo -ne '\nstopping container...' && docker stop refinery-updater > /dev/null 2>&1 && echo -ne '\t\t [done]\n'" EXIT
319

420
HOST_IP=$(docker network inspect bridge --format='{{json .IPAM.Config}}' | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | tail -1)
@@ -8,12 +24,13 @@ docker stop refinery-updater > /dev/null 2>&1
824
echo -ne '\t [done]\n'
925

1026
echo -ne 'building container...'
11-
docker build -t refinery-updater-dev -f dev.Dockerfile . > /dev/null 2>&1
27+
docker build -t refinery-updater-dev -f dev.Dockerfile .
1228
echo -ne '\t\t [done]\n'
1329

1430
echo -ne 'starting...'
1531
docker run -d --rm \
1632
--name refinery-updater \
33+
-p $DEBUG_PORT:$DEBUG_PORT \
1734
-p 7062:80 \
1835
-e S3_ENDPOINT_LOCAL=object-storage:9000 \
1936
-e S3_ACCESS_KEY=kern \
@@ -24,7 +41,10 @@ docker run -d --rm \
2441
--mount type=bind,source="$(pwd)"/,target=/app \
2542
-v /var/run/docker.sock:/var/run/docker.sock \
2643
--network dev-setup_default \
27-
refinery-updater-dev > /dev/null 2>&1
44+
refinery-updater-dev $CMD > /dev/null 2>&1
2845
echo -ne '\t\t\t [done]\n'
2946

47+
if [ $DEBUG_MODE = true ]; then
48+
echo -e "\033[0;33muse VSCode Debugger (Python Debugger: refinery-updater) to start the service\033[0m"
49+
fi
3050
docker logs -f refinery-updater

0 commit comments

Comments
 (0)