This commit is contained in:
37
server.py
37
server.py
@@ -1,5 +1,3 @@
|
||||
import subprocess
|
||||
|
||||
from granian.constants import Interfaces
|
||||
from granian.log import LogLevels
|
||||
from granian.server import Granian
|
||||
@@ -8,23 +6,24 @@ from settings import PORT
|
||||
from utils.logger import root_logger as logger
|
||||
|
||||
|
||||
def is_docker_container_running(name):
|
||||
cmd = ["docker", "ps", "-f", f"name={name}"]
|
||||
output = subprocess.run(cmd, capture_output=True, text=True).stdout
|
||||
logger.info(output)
|
||||
return name in output
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.info("started")
|
||||
|
||||
granian_instance = Granian(
|
||||
"main:app",
|
||||
address="0.0.0.0", # noqa S104
|
||||
port=PORT,
|
||||
interface=Interfaces.ASGI,
|
||||
threads=4,
|
||||
websockets=False,
|
||||
log_level=LogLevels.debug,
|
||||
)
|
||||
granian_instance.serve()
|
||||
try:
|
||||
granian_instance = Granian(
|
||||
"main:app",
|
||||
address="0.0.0.0",
|
||||
port=PORT,
|
||||
interface=Interfaces.ASGI,
|
||||
threads=4,
|
||||
websockets=False,
|
||||
log_level=LogLevels.debug,
|
||||
backlog=2048,
|
||||
)
|
||||
|
||||
granian_instance.serve()
|
||||
except Exception as error:
|
||||
logger.error(f"Granian error: {error}", exc_info=True)
|
||||
raise
|
||||
finally:
|
||||
logger.info("stopped")
|
||||
|
Reference in New Issue
Block a user