feat: gitea workflow with Uploader check is runing, plus in server.py is checker too
This commit is contained in:
27
server.py
27
server.py
@@ -1,18 +1,27 @@
|
||||
import subprocess
|
||||
from granian.constants import Interfaces
|
||||
from granian.server import Granian
|
||||
|
||||
from services.logger import root_logger as logger
|
||||
from settings import PORT
|
||||
|
||||
def is_docker_container_running(name):
|
||||
cmd = ['docker', 'ps', '-f', f'name={name}']
|
||||
output = subprocess.run(cmd, capture_output=True, text=True).stdout
|
||||
return name in output
|
||||
|
||||
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,
|
||||
)
|
||||
granian_instance.serve()
|
||||
if is_docker_container_running('uploader'):
|
||||
granian_instance = Granian(
|
||||
"main:app",
|
||||
address="0.0.0.0", # noqa S104
|
||||
port=PORT,
|
||||
threads=4,
|
||||
websockets=False,
|
||||
interface=Interfaces.ASGI,
|
||||
)
|
||||
granian_instance.serve()
|
||||
else:
|
||||
logger.info("'uploader' is not running. But very needed !!! \(^.^'\)")
|
Reference in New Issue
Block a user