-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
31 lines (24 loc) · 1011 Bytes
/
start.py
File metadata and controls
31 lines (24 loc) · 1011 Bytes
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
27
28
29
30
31
import subprocess
import threading
# プログラム終了方法
# 1 終了するにはuuuと入力→enter
# 2 終了処理を開始します...と出たらctrl+c
# 3 出なかったら1からもう一回
process = subprocess.Popen(["tailscale", "funnel", "http://127.0.0.1:8192"]) #funnel
scripts = ["flask_app.py", "gui.py", "check_time.py", "chat.py"]
# 各スクリプトを並列で起動
processes = [subprocess.Popen(["python3", script]) for script in scripts]
def monitor_input():
while True:
command = input()
if command.strip().lower() == "uuu":
print("終了処理を開始します...")
for p in processes:
p.terminate() # プロセスを終了
process.terminate() # funnelプロセスも終了
break
# ユーザー入力を監視するスレッドを開始
threading.Thread(target=monitor_input, daemon=True).start()
# すべてのプロセスが終了するまで待機
for p in processes:
p.wait()