Update server.py
Browse files
server.py
CHANGED
|
@@ -47,6 +47,8 @@ def execute_commands(port_and_commands_json):
|
|
| 47 |
# 解析 JSON 字符串
|
| 48 |
port_and_commands_list = json.loads(port_and_commands_json)
|
| 49 |
|
|
|
|
|
|
|
| 50 |
for item in port_and_commands_list:
|
| 51 |
port = item['port']
|
| 52 |
command = item['command']
|
|
@@ -54,9 +56,11 @@ def execute_commands(port_and_commands_json):
|
|
| 54 |
# 构造完整的命令字符串
|
| 55 |
full_command = f'python /home/aistudio/work/GPT-SoVITS/api.py -p {port} {command}'
|
| 56 |
|
| 57 |
-
# 执行命令
|
| 58 |
print(f'Executing command on port {port}: {full_command}')
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
except json.JSONDecodeError as e:
|
| 61 |
print(f"Failed to decode JSON: {e}")
|
| 62 |
except Exception as e:
|
|
|
|
| 47 |
# 解析 JSON 字符串
|
| 48 |
port_and_commands_list = json.loads(port_and_commands_json)
|
| 49 |
|
| 50 |
+
processes = [] # 用于存储进程对象
|
| 51 |
+
|
| 52 |
for item in port_and_commands_list:
|
| 53 |
port = item['port']
|
| 54 |
command = item['command']
|
|
|
|
| 56 |
# 构造完整的命令字符串
|
| 57 |
full_command = f'python /home/aistudio/work/GPT-SoVITS/api.py -p {port} {command}'
|
| 58 |
|
| 59 |
+
# 执行命令并将其放入后台
|
| 60 |
print(f'Executing command on port {port}: {full_command}')
|
| 61 |
+
process = subprocess.Popen(full_command, shell=True) # 使用 Popen 启动进程
|
| 62 |
+
processes.append(process) # 将进程对象添加到列表
|
| 63 |
+
|
| 64 |
except json.JSONDecodeError as e:
|
| 65 |
print(f"Failed to decode JSON: {e}")
|
| 66 |
except Exception as e:
|