Skip to content

Debug support #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ dmypy.json
.pyre/

# VSCode
.vscode
.vscode/*
!.vscode/launch.json
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: refinery-updater",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 15674
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
}
]
}
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-r requirements.txt
httpx==0.25.0
pytest==8.1.1
pytest==8.1.1
debugpy==1.8.12
24 changes: 22 additions & 2 deletions start
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/bash

DEBUG_MODE=false
DEBUG_PORT=15674

while getopts d flag
do
case "${flag}" in
d) DEBUG_MODE=true;;
esac
done

CMD=""
if [ $DEBUG_MODE = true ]; then
CMD="debugpy --wait-for-client --listen 0.0.0.0:$DEBUG_PORT -m uvicorn app:app --host 0.0.0.0 --port 80 --reload"
fi

trap "echo -ne '\nstopping container...' && docker stop refinery-updater > /dev/null 2>&1 && echo -ne '\t\t [done]\n'" EXIT

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)
Expand All @@ -8,12 +24,13 @@ docker stop refinery-updater > /dev/null 2>&1
echo -ne '\t [done]\n'

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

echo -ne 'starting...'
docker run -d --rm \
--name refinery-updater \
-p $DEBUG_PORT:$DEBUG_PORT \
-p 7062:80 \
-e S3_ENDPOINT_LOCAL=object-storage:9000 \
-e S3_ACCESS_KEY=kern \
Expand All @@ -24,7 +41,10 @@ docker run -d --rm \
--mount type=bind,source="$(pwd)"/,target=/app \
-v /var/run/docker.sock:/var/run/docker.sock \
--network dev-setup_default \
refinery-updater-dev > /dev/null 2>&1
refinery-updater-dev $CMD > /dev/null 2>&1
echo -ne '\t\t\t [done]\n'

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