mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2026-02-25 02:20:17 +00:00
✨ api "production" script: invoke granian without "click" hack
This commit is contained in:
parent
ca46a2cf5c
commit
30d1c5fba9
1 changed files with 11 additions and 20 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from granian.cli import cli as granian_cli
|
from granian import Granian
|
||||||
|
from granian.constants import Interfaces, Loops
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
|
@ -36,23 +37,13 @@ def start():
|
||||||
os.environ["ADVENT22__PRODUCTION_MODE"] = "true"
|
os.environ["ADVENT22__PRODUCTION_MODE"] = "true"
|
||||||
|
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
granian_cli(
|
server = Granian(
|
||||||
[
|
|
||||||
"--host",
|
|
||||||
settings.bind.host,
|
|
||||||
"--port",
|
|
||||||
settings.bind.port,
|
|
||||||
"--workers",
|
|
||||||
settings.workers.count,
|
|
||||||
"--interface",
|
|
||||||
"asgi",
|
|
||||||
"--loop",
|
|
||||||
"uvloop",
|
|
||||||
"--process-name",
|
|
||||||
"advent22",
|
|
||||||
# app
|
|
||||||
"advent22_api.app:app",
|
"advent22_api.app:app",
|
||||||
],
|
address=settings.bind.host,
|
||||||
auto_envvar_prefix="GRANIAN",
|
port=settings.bind.port,
|
||||||
standalone_mode=False,
|
workers=settings.workers.count,
|
||||||
|
interface=Interfaces.ASGI,
|
||||||
|
loop=Loops.uvloop,
|
||||||
|
process_name="advent22",
|
||||||
)
|
)
|
||||||
|
server.serve()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue