granian-dry-test
This commit is contained in:
parent
b98da839ed
commit
fe53ff6afc
|
@ -13,11 +13,11 @@ python = "^3.12"
|
||||||
SQLAlchemy = "^2.0.22"
|
SQLAlchemy = "^2.0.22"
|
||||||
psycopg2-binary = "^2.9.9"
|
psycopg2-binary = "^2.9.9"
|
||||||
redis = {extras = ["hiredis"], version = "^5.0.1"}
|
redis = {extras = ["hiredis"], version = "^5.0.1"}
|
||||||
uvicorn = "^0.27.0"
|
|
||||||
strawberry-graphql = {extras = ["asgi", "debug-server"], version = "^0.216.1" }
|
strawberry-graphql = {extras = ["asgi", "debug-server"], version = "^0.216.1" }
|
||||||
strawberry-sqlalchemy-mapper = "^0.4.0"
|
strawberry-sqlalchemy-mapper = "^0.4.0"
|
||||||
sentry-sdk = "^1.37.1"
|
sentry-sdk = "^1.37.1"
|
||||||
aiohttp = "^3.9.1"
|
aiohttp = "^3.9.1"
|
||||||
|
granian = "^1.0.2"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
setuptools = "^69.0.2"
|
setuptools = "^69.0.2"
|
||||||
|
|
23
server.py
23
server.py
|
@ -1,7 +1,5 @@
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
import uvicorn
|
|
||||||
from uvicorn.main import logger
|
|
||||||
|
|
||||||
from settings import PORT
|
from settings import PORT
|
||||||
|
|
||||||
|
@ -49,6 +47,9 @@ local_headers = [
|
||||||
("Access-Control-Allow-Credentials", "true"),
|
("Access-Control-Allow-Credentials", "true"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
logger = logging.getLogger("[server] ")
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
def exception_handler(_et, exc, _tb):
|
def exception_handler(_et, exc, _tb):
|
||||||
logger.error(..., exc_info=(type(exc), exc, exc.__traceback__))
|
logger.error(..., exc_info=(type(exc), exc, exc.__traceback__))
|
||||||
|
@ -56,4 +57,18 @@ def exception_handler(_et, exc, _tb):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.excepthook = exception_handler
|
sys.excepthook = exception_handler
|
||||||
uvicorn.run("main:app", host="0.0.0.0", port=PORT, proxy_headers=True, server_header=True)
|
from granian.constants import Interfaces
|
||||||
|
from granian.server import Granian
|
||||||
|
|
||||||
|
print("[server] started")
|
||||||
|
|
||||||
|
granian_instance = Granian(
|
||||||
|
"main:app",
|
||||||
|
address="0.0.0.0", # noqa S104
|
||||||
|
port=PORT,
|
||||||
|
workers=2,
|
||||||
|
threads=2,
|
||||||
|
websockets=False,
|
||||||
|
interface=Interfaces.ASGI,
|
||||||
|
)
|
||||||
|
granian_instance.serve()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user