Skip to content

Commit 16c078b

Browse files
Debug support (#47)
* perf: add debug support * perf: align start script to others
1 parent 474b4a1 commit 16c078b

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
__pycache__
22
.git
3-
.vscode/settings.json
3+
.vscode/*
4+
!.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-authorizer",
9+
"type": "debugpy",
10+
"request": "attach",
11+
"connect": {
12+
"host": "localhost",
13+
"port": 15672
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,19 +1,39 @@
11
#!/bin/bash
2+
3+
DEBUG_MODE=false
4+
DEBUG_PORT=15672
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 main:app --host 0.0.0.0 --port 80 --reload"
16+
fi
17+
218
trap "echo -ne '\nstopping container...' && docker stop refinery-authorizer > /dev/null 2>&1 && echo -ne '\t\t [done]\n'" EXIT
319

420
echo -ne 'stopping old container...'
521
docker stop refinery-authorizer > /dev/null 2>&1
622
echo -ne '\t [done]\n'
723

824
echo -ne 'building container...'
9-
docker build -t refinery-authorizer-dev -f dev.Dockerfile . > /dev/null 2>&1
25+
docker build -t refinery-authorizer-dev -f dev.Dockerfile .
1026
echo -ne '\t\t [done]\n'
1127

1228
echo -ne 'starting...'
1329
docker run -d --rm \
1430
--name refinery-authorizer \
31+
-p $DEBUG_PORT:$DEBUG_PORT \
1532
--network dev-setup_default \
16-
refinery-authorizer-dev > /dev/null 2>&1
33+
refinery-authorizer-dev $CMD > /dev/null 2>&1
1734
echo -ne '\t\t\t [done]\n'
1835

36+
if [ $DEBUG_MODE = true ]; then
37+
echo -e "\033[0;33muse VSCode Debugger (Python Debugger: refinery-authorizer) to start the service\033[0m"
38+
fi
1939
docker logs -f refinery-authorizer

0 commit comments

Comments
 (0)