Skip to content

Commit

Permalink
Change granian to uvicorn webserver
Browse files Browse the repository at this point in the history
  • Loading branch information
berrydenhartog committed May 15, 2024
1 parent e68ea51 commit 9e704c8
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 138 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"name": "tad - fastapi",
"type": "debugpy",
"request": "launch",
"module": "granian",
"module": "uvicorn",
"justMyCode": true,
"args": ["--interface","asgi","tad.main:app", "--reload"],
"args": ["tad.main:app"],
"cwd": "${workspaceFolder}/",
"env": {
"PYTHONPATH": "${workspaceFolder}"
Expand Down
6 changes: 5 additions & 1 deletion BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ poetry install
When poetry is done installing all dependencies you can start using the tool.

```shell
poetry run python -m granian --interface asgi tad.main:app
poetry run python -m uvicorn tad.main:app --log-level warning
```

## Database

We support most SQL database types. You can use the variable `APP_DATABASE_SCHEME` to change the database. The default scheme is sqlite.

If you change the `models` at tad/models of the application you can generate a new migration file

```shell
alembic revision --autogenerate -m "a message"
```

Please make sure you check the auto generated file in tad/migrations/

to upgrade to the latest version of the database schema use

```shell
alembic upgrade head
```
Expand Down Expand Up @@ -71,11 +73,13 @@ For testing, linting and other feature we use several tools. You can look up the
## Updating dependencies

Use poetry to update all python project dependencies

```shell
poetry update
```

Use pre-commit to update all hooks

```shell
pre-commit autoupdate
```
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ COPY --chown=root:root --chmod=755 LICENSE /app/LICENSE
ENV PYTHONPATH=/app/
WORKDIR /app/

CMD ["python", "-m", "granian", "--host", "0.0.0.0","--interface","asgi","tad.main:app" ]
CMD ["python", "-m", "uvicorn", "--host", "0.0.0.0", "tad.main:app", "--log-level", "warning" ]
3 changes: 0 additions & 3 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ services:
- SECRET_KEY=${SECRET_KEY:?Variable not set}
healthcheck:
test: ["CMD", "pg_isready", "-q", "-d", "tad", "-U", "tad"]
start_period: 3s


db-admin:
image: dpage/pgadmin4:8.6
Expand All @@ -51,7 +49,6 @@ services:
healthcheck:
test: ["CMD", "wget", "-O", "-", "http://localhost:8080/misc/ping"]


#TODO(berry): Traefik

volumes:
Expand Down
329 changes: 200 additions & 129 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ alembic = "^1.13.1"
pydantic = "^2.7.1"
jinja2 = "^3.1.4"
pydantic-settings = "^2.2.1"
granian = {extras = ["reload"], version = "^1.3.1"}
psycopg2-binary = "^2.9.9"
uvicorn = {extras = ["standard"], version = "^0.29.0"}

[tool.poetry.group.test.dependencies]
pytest = "^8.1.1"
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ sonar.python.version=3.10,3.11,3.12

sonar.python.coverage.reportPaths=coverage.xml

sonar.coverage.exclusions="tad/migration/*"
sonar.coverage.exclusions=tad/migration/

0 comments on commit 9e704c8

Please sign in to comment.