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