This commit is contained in:
parent
edece36ecc
commit
a4a3c35f4d
|
@ -13,4 +13,4 @@ RUN pip install -r requirements.txt
|
|||
|
||||
COPY . .
|
||||
|
||||
CMD ["python", "server.py"]
|
||||
CMD ["python", "-m", "granian", "main:app", "--interface", "asgi", "--host", "0.0.0.0", "--port", "$PORT"]
|
32
server.py
32
server.py
|
@ -1,32 +0,0 @@
|
|||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from granian import Granian
|
||||
from granian.constants import Interfaces
|
||||
from granian.log import LogLevels
|
||||
|
||||
from settings import PORT
|
||||
from utils.logger import root_logger as logger
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.info("started")
|
||||
try:
|
||||
granian_instance = Granian(
|
||||
"main:app",
|
||||
address="0.0.0.0",
|
||||
port=PORT,
|
||||
interface=Interfaces.ASGI,
|
||||
websockets=False,
|
||||
log_level=LogLevels.debug,
|
||||
backlog=2048,
|
||||
)
|
||||
|
||||
if "dev" in sys.argv:
|
||||
logger.info("dev mode, building ssl context")
|
||||
granian_instance.build_ssl_context(cert=Path("localhost.pem"), key=Path("localhost-key.pem"), password=None)
|
||||
granian_instance.serve()
|
||||
except Exception as error:
|
||||
logger.error(error, exc_info=True)
|
||||
raise
|
||||
finally:
|
||||
logger.info("stopped")
|
|
@ -1,5 +1,4 @@
|
|||
from decimal import Decimal
|
||||
|
||||
from json import JSONEncoder
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user