File size: 730 Bytes
2a822b1
183ee92
981678c
2a822b1
981678c
 
 
 
2a822b1
 
 
9fe1f6c
2a822b1
 
9fe1f6c
 
 
183ee92
9fe1f6c
 
 
183ee92
9fe1f6c
 
f6005b0
7d5dbff
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

subprocess.run(["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"])

#command = ["arecord" "-l"]
#print(command)
#result = subprocess.run(command, stdout=subprocess.PIPE, text=True)
#print("Output:\n", result.stdout)
#os.system("uvicorn server:app --reload")

"""
def start_server():   
    os.system("uvicorn server:app --port 8080 --workers 2")

def is_port_in_use(port):   
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        return s.connect_ex(('0.0.0.0', port)) == 0

def main():
    if is_port_in_use(8080):
        print("Port 8080 is already in use. Please kill the process and try again.")
    else:
        start_server()
        
    main()   
"""