Skip to content

Commit

Permalink
Hypercorn (#35)
Browse files Browse the repository at this point in the history
* runs w gunicorn

* updated starter script

* uvicorn logs now collected in uvicorn.log file

* added log conf

* added host option

* misc updates

* hypercorn implementation works yay

* logs shoowing up in /tmp

* updated log conf

* now logs to files in local dir

* removed guincorn start script and renamed other script to start_app

* updated deps
  • Loading branch information
fullerzz authored Jul 17, 2024
1 parent 846ac14 commit 1fff170
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 349 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ cython_debug/
scripts/*
!scripts/start_dev.sh
!scripts/test.sh
!scripts/start_app.sh

# local file cache
uploads/*
Expand Down
48 changes: 48 additions & 0 deletions logging.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[loggers]
keys=root, hypercorn.error, hypercorn.access

[handlers]
keys=console, error_file, access_file

[formatters]
keys=generic, access

[logger_root]
level=DEBUG
handlers=console

[logger_hypercorn.error]
level=INFO
handlers=error_file
propagate=1
qualname=hypercorn.error

[logger_hypercorn.access]
level=DEBUG
handlers=access_file
propagate=0
qualname=hypercorn.access

[handler_console]
class=StreamHandler
formatter=generic
args=(sys.stdout, )

[handler_error_file]
class=logging.FileHandler
formatter=generic
args=('hypercorn.error.log',)

[handler_access_file]
class=logging.FileHandler
formatter=access
args=('hypercorn.access.log',)

[formatter_generic]
format=%(asctime)s [%(process)d] [%(levelname)s] %(message)s
datefmt=%Y-%m-%d %H:%M:%S
class=logging.Formatter

[formatter_access]
format=%(message)s
class=logging.Formatter
322 changes: 120 additions & 202 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ fastapi = "^0.111.0"
sqlmodel = "^0.0.19"
rich = "^13.7.1"
python-multipart = "^0.0.9"
beartype = "^0.18.5"
python-dotenv = "^1.0.1"
pydantic-settings = "^2.3.4"

hypercorn = "^0.17.3"

[tool.poetry.group.dev.dependencies]
boto3-stubs = {extras = ["essential"], version = "^1.34.136"}
Expand All @@ -28,7 +27,6 @@ pytest = "^8.2.2"
pytest-asyncio = "^0.23.7"
moto = {extras = ["all"], version = "^5.0.10"}


[tool.ruff]
line-length = 120
indent-width = 4
Expand Down
158 changes: 21 additions & 137 deletions requirements.txt

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions scripts/start_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

poetry run hypercorn src.smolvault.main:app -b 0.0.0.0 --debug --log-config=logging.conf --log-level=DEBUG --access-logfile=hypercorn.access.log --error-logfile=hypercorn.error.log --keep-alive=120 --workers=1
3 changes: 0 additions & 3 deletions scripts/start_dev.sh

This file was deleted.

3 changes: 0 additions & 3 deletions src/smolvault/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from beartype.claw import beartype_this_package # <-- this is boring, but...

beartype_this_package() # <-- the fast way
2 changes: 1 addition & 1 deletion src/smolvault/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

logging.basicConfig(
handlers=[RotatingFileHandler("app.log", maxBytes=100_000, backupCount=10), logging.StreamHandler(sys.stdout)],
level=logging.DEBUG,
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
logger = logging.getLogger(__name__)
Expand Down

0 comments on commit 1fff170

Please sign in to comment.