diff --git a/backend/linkpulse/__main__.py b/backend/linkpulse/__main__.py index ebb0155..2e4afbc 100644 --- a/backend/linkpulse/__main__.py +++ b/backend/linkpulse/__main__.py @@ -1,16 +1,19 @@ import sys +import structlog + +import linkpulse.logging +logger = structlog.get_logger() def main(*args): if args[0] == "serve": import asyncio - from hypercorn import Config - from hypercorn.asyncio import serve from linkpulse.app import app + from uvicorn import run - config = Config() - config.use_reloader = True - asyncio.run(serve(app, config)) + logger.debug('Invoking uvicorn.run') + run('linkpulse.app:app', reload=True, host='0.0.0.0', access_log=True) + elif args[0] == "migrate": from linkpulse.migrate import main diff --git a/backend/poetry.lock b/backend/poetry.lock index 0cfc44f..62ff562 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -70,6 +70,24 @@ tornado = ["tornado (>=4.3)"] twisted = ["twisted"] zookeeper = ["kazoo"] +[[package]] +name = "asgi-correlation-id" +version = "4.3.4" +description = "Middleware correlating project logs to individual requests" +optional = false +python-versions = "<4.0,>=3.8" +files = [ + {file = "asgi_correlation_id-4.3.4-py3-none-any.whl", hash = "sha256:36ce69b06c7d96b4acb89c7556a4c4f01a972463d3d49c675026cbbd08e9a0a2"}, + {file = "asgi_correlation_id-4.3.4.tar.gz", hash = "sha256:ea6bc310380373cb9f731dc2e8b2b6fb978a76afe33f7a2384f697b8d6cd811d"}, +] + +[package.dependencies] +packaging = "*" +starlette = ">=0.18" + +[package.extras] +celery = ["celery"] + [[package]] name = "blessed" version = "1.20.0" @@ -460,32 +478,6 @@ files = [ {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] -[[package]] -name = "h2" -version = "4.1.0" -description = "HTTP/2 State-Machine based protocol implementation" -optional = false -python-versions = ">=3.6.1" -files = [ - {file = "h2-4.1.0-py3-none-any.whl", hash = "sha256:03a46bcf682256c95b5fd9e9a99c1323584c3eec6440d379b9903d709476bc6d"}, - {file = "h2-4.1.0.tar.gz", hash = "sha256:a83aca08fbe7aacb79fec788c9c0bac936343560ed9ec18b82a13a12c28d2abb"}, -] - -[package.dependencies] -hpack = ">=4.0,<5" -hyperframe = ">=6.0,<7" - -[[package]] -name = "hpack" -version = "4.0.0" -description = "Pure-Python HPACK header compression" -optional = false -python-versions = ">=3.6.1" -files = [ - {file = "hpack-4.0.0-py3-none-any.whl", hash = "sha256:84a076fad3dc9a9f8063ccb8041ef100867b1878b25ef0ee63847a5d53818a6c"}, - {file = "hpack-4.0.0.tar.gz", hash = "sha256:fc41de0c63e687ebffde81187a948221294896f6bdc0ae2312708df339430095"}, -] - [[package]] name = "human-readable" version = "1.3.4" @@ -497,40 +489,6 @@ files = [ {file = "human_readable-1.3.4.tar.gz", hash = "sha256:5726eac89066ec25d14447a173e645a855184645d024eb306705e2bfbb60f0c0"}, ] -[[package]] -name = "hypercorn" -version = "0.14.4" -description = "A ASGI Server based on Hyper libraries and inspired by Gunicorn" -optional = false -python-versions = ">=3.7" -files = [ - {file = "hypercorn-0.14.4-py3-none-any.whl", hash = "sha256:f956200dbf8677684e6e976219ffa6691d6cf795281184b41dbb0b135ab37b8d"}, - {file = "hypercorn-0.14.4.tar.gz", hash = "sha256:3fa504efc46a271640023c9b88c3184fd64993f47a282e8ae1a13ccb285c2f67"}, -] - -[package.dependencies] -h11 = "*" -h2 = ">=3.1.0" -priority = "*" -wsproto = ">=0.14.0" - -[package.extras] -docs = ["pydata_sphinx_theme"] -h3 = ["aioquic (>=0.9.0,<1.0)"] -trio = ["exceptiongroup (>=1.1.0)", "trio (>=0.22.0)"] -uvloop = ["uvloop"] - -[[package]] -name = "hyperframe" -version = "6.0.1" -description = "HTTP/2 framing layer for Python" -optional = false -python-versions = ">=3.6.1" -files = [ - {file = "hyperframe-6.0.1-py3-none-any.whl", hash = "sha256:0ec6bafd80d8ad2195c4f03aacba3a8265e57bc4cff261e802bf39970ed02a15"}, - {file = "hyperframe-6.0.1.tar.gz", hash = "sha256:ae510046231dc8e9ecb1a6586f63d2347bf4c8905914aa84ba585ae85f28a914"}, -] - [[package]] name = "idna" version = "3.10" @@ -573,6 +531,17 @@ files = [ [package.dependencies] psutil = "*" +[[package]] +name = "packaging" +version = "24.1" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, + {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, +] + [[package]] name = "peewee" version = "3.17.7" @@ -697,17 +666,6 @@ tzdata = ">=2020.1" [package.extras] test = ["time-machine (>=2.6.0)"] -[[package]] -name = "priority" -version = "2.0.0" -description = "A pure-Python implementation of the HTTP/2 priority tree" -optional = false -python-versions = ">=3.6.1" -files = [ - {file = "priority-2.0.0-py3-none-any.whl", hash = "sha256:6f8eefce5f3ad59baf2c080a664037bb4725cd0a790d53d59ab4059288faf6aa"}, - {file = "priority-2.0.0.tar.gz", hash = "sha256:c965d54f1b8d0d0b19479db3924c7c36cf672dbf2aec92d43fbdaf4492ba18c0"}, -] - [[package]] name = "prompt-toolkit" version = "3.0.36" @@ -1154,21 +1112,7 @@ files = [ {file = "wcwidth-0.2.13.tar.gz", hash = "sha256:72ea0c06399eb286d978fdedb6923a9eb47e1c486ce63e9b4e64fc18303972b5"}, ] -[[package]] -name = "wsproto" -version = "1.2.0" -description = "WebSockets state-machine based protocol implementation" -optional = false -python-versions = ">=3.7.0" -files = [ - {file = "wsproto-1.2.0-py3-none-any.whl", hash = "sha256:b9acddd652b585d75b20477888c56642fdade28bdfd3579aa24a4d2c037dd736"}, - {file = "wsproto-1.2.0.tar.gz", hash = "sha256:ad565f26ecb92588a3e43bc3d96164de84cd9902482b130d0ddbaa9664a85065"}, -] - -[package.dependencies] -h11 = ">=0.9.0,<1" - [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "2f0468d968bebbc7da62d53cf5d2e53c7cd0a1f91618f8aead2f331248d8aeef" +content-hash = "301e6babf2c3116cc910e1269a8d05d734fc9e8c8a80cd67767b331227c2a72d" diff --git a/backend/pyproject.toml b/backend/pyproject.toml index c319f77..7af628c 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -13,7 +13,6 @@ app = "linkpulse" [tool.poetry.dependencies] python = "^3.12" fastapi = "0.100" -Hypercorn = "0.14.4" python-dotenv = "^1.0.1" peewee = "^3.17.7" peewee-migrate = "^1.13.0" @@ -25,6 +24,8 @@ apscheduler = "^3.10.4" human-readable = "^1.3.4" psycopg2 = "^2.9.10" structlog = "^24.4.0" +uvicorn = "^0.32.0" +asgi-correlation-id = "^4.3.4" [tool.poetry.group.dev.dependencies]