File size: 749 Bytes
c17ee23
583f924
c17ee23
583f924
 
 
2e0dcd8
 
583f924
c17ee23
2e0dcd8
c17ee23
 
 
7b98d63
 
c17ee23
 
7b98d63
c17ee23
 
 
e55694e
c17ee23
e55694e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import subprocess
import logging

# Configure logging
logging.basicConfig(
    level=logging.DEBUG,
    format="%(asctime)s - %(levelname)s - %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S",
)


def run_command(command):
    try:
        output = subprocess.check_output(
            command, shell=True, stderr=subprocess.STDOUT, universal_newlines=True
        )
        print(output)
    except subprocess.CalledProcessError as e:
        print(f"Command execution failed with return code {e.returncode}: {e.output}")


# Example usage
command = "uvicorn App.app:app --host 0.0.0.0 --port 7860 & celery -A App.Worker.celery worker -c 8 --loglevel=info"
run_command(command)
# "python3.10 -m celery -A App.Worker.celery worker -c 8 --loglevel=info"