Files
core/server.py

29 lines
664 B
Python
Raw Normal View History

2024-05-07 00:06:31 +03:00
import subprocess
from granian.constants import Interfaces
from granian.server import Granian
2024-05-07 00:06:31 +03:00
2024-08-07 08:57:56 +03:00
from utils.logger import root_logger as logger
2024-02-21 23:14:06 +03:00
from settings import PORT
2024-05-06 10:53:27 +03:00
def is_docker_container_running(name):
2024-05-06 10:53:27 +03:00
cmd = ["docker", "ps", "-f", f"name={name}"]
output = subprocess.run(cmd, capture_output=True, text=True).stdout
2024-05-06 10:58:31 +03:00
logger.info(output)
return name in output
2024-05-06 10:53:27 +03:00
2024-04-17 18:32:23 +03:00
if __name__ == "__main__":
logger.info("started")
granian_instance = Granian(
"main:app",
address="0.0.0.0", # noqa S104
port=PORT,
threads=4,
websockets=False,
interface=Interfaces.ASGI,
)
2024-05-06 10:53:27 +03:00
granian_instance.serve()