Skip to content

Commit

Permalink
feat: 删除网关模式
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Aug 17, 2024
1 parent cca6e47 commit e401a73
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 156 deletions.
26 changes: 1 addition & 25 deletions xiaomusic/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,39 +153,15 @@ def run_server(port):
log_config=LOGGING_CONFIG,
)

process = None

def run_gate():
command = [
"uvicorn",
"xiaomusic.gate:app",
"--workers",
"4",
"--host",
"0.0.0.0",
"--port",
str(config.port),
]
global process
process = subprocess.Popen(command)

def signal_handler(sig, frame):
print("主进程收到退出信号,准备退出...")
if process is not None:
process.terminate() # 终止子进程
process.wait() # 等待子进程退出
print("子进程已退出")
os._exit(0) # 退出主进程

# 捕获主进程的退出信号
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
port = int(config.port)
if config.enable_gate:
run_gate()
run_server(port + 1)
else:
run_server(port)
run_server(port)


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion xiaomusic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class Config:
os.getenv("XIAOMUSIC_REMOVE_ID3TAG", "false").lower() == "true"
)
delay_sec: int = int(os.getenv("XIAOMUSIC_DELAY_SEC", 3)) # 下一首歌延迟播放秒数
enable_gate: bool = os.getenv("XIAOMUSIC_ENABLE_GATE", "false").lower() == "true"

def append_keyword(self, keys, action):
for key in keys.split(","):
Expand Down
124 changes: 0 additions & 124 deletions xiaomusic/gate.py

This file was deleted.

6 changes: 0 additions & 6 deletions xiaomusic/static/setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ <h2>小爱音箱设置面板
<option value="false">false</option>
</select>

<label for="enable_gate">开启网关(重启生效):</label>
<select id="enable_gate">
<option value="true">true</option>
<option value="false" selected>false</option>
</select>

<label for="use_music_api">触屏版兼容模式:</label>
<select id="use_music_api">
<option value="true">true</option>
Expand Down

0 comments on commit e401a73

Please sign in to comment.