1
0
mirror of https://github.com/hanxi/xiaomusic.git synced 2026-03-15 08:13:16 +08:00

build: 调试

This commit is contained in:
涵曦
2024-12-18 21:36:14 +08:00
parent a510f9162e
commit b0dfb37d98
4 changed files with 24 additions and 18 deletions

View File

@@ -18,8 +18,7 @@ COPY --from=builder /app/xiaomusic.py .
COPY --from=builder /app/xiaomusic/__init__.py /base_version.py
RUN touch /app/.dockerenv
RUN mkdir -p /etc/supervisor/conf.d
COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
COPY supervisor.conf /etc/supervisor.conf
ENV XIAOMUSIC_HOSTNAME=192.168.2.5
ENV XIAOMUSIC_PORT=8090
@@ -29,4 +28,4 @@ EXPOSE 8090
ENV TZ=Asia/Shanghai
ENV PATH=/app/.venv/bin:$PATH
CMD ["/usr/bin/supervisord", "-n"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor.conf"]

View File

@@ -1,5 +1,16 @@
[unix_http_server]
file=/var/run/supervisor.sock ; Unix套接字文件路径
chmod=0777 ; 套接字权限
[supervisord]
nodaemon=true # 确保 supervisord 在前台运行,以便 Docker 容器不会退出
nodaemon=true ; 非守护模式,适合容器运行
pidfile=/tmp/supervisord.pid ; PID文件路径
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; 使用Unix套接字与服务通信
[program:xiaomusic]
command=/app/.venv/bin/python3 /app/xiaomusic.py

View File

@@ -588,18 +588,11 @@ async def playlistdelmusic(data: PlayListMusicObj, Verifcation=Depends(verificat
async def updateversion(
version: str = "", lite: bool = True, Verifcation=Depends(verification)
):
ret = update_version(version, lite)
ret = await update_version(version, lite)
if ret != "OK":
return {"ret": ret}
proc = restart_xiaomusic()
async def check_proc():
# 等待子进程完成
exit_code = await proc.wait()
log.info(f"Restart completed with exit code {exit_code}")
asyncio.create_task(check_proc())
asyncio.create_task(restart_xiaomusic())
return {"ret": "OK"}

View File

@@ -1029,7 +1029,9 @@ async def restart_xiaomusic():
cmd = " ".join(sbp_args)
log.info(f"restart_xiaomusic: {cmd}")
proc = await asyncio.create_subprocess_exec(*sbp_args)
return proc
exit_code = await proc.wait() # 等待子进程完成
log.info(f"restart_xiaomusic completed with exit code {exit_code}")
return exit_code
async def update_version(version: str, lite: bool = True):
@@ -1047,9 +1049,7 @@ async def update_version(version: str, lite: bool = True):
# https://github.com/hanxi/xiaomusic/releases/download/main/app-amd64-lite.tar.gz
url = f"https://github.hanxi.cc/proxy/hanxi/xiaomusic/releases/download/{version}/app-{arch}{lite_tag}.tar.gz"
target_directory = "/app"
await download_and_extract(url, target_directory)
return "OK"
return await download_and_extract(url, target_directory)
def get_os_architecture():
@@ -1072,6 +1072,7 @@ def get_os_architecture():
async def download_and_extract(url: str, target_directory: str):
ret = "OK"
# 创建目标目录
os.makedirs(target_directory, exist_ok=True)
@@ -1095,7 +1096,9 @@ async def download_and_extract(url: str, target_directory: str):
tar.extractall(path=target_directory)
log.info(f"文件解压完成到: {target_directory}")
else:
log.warning(f"下载失败, 状态码: {response.status}")
ret = f"下载失败, 状态码: {response.status}"
log.warning(ret)
return ret
def chmodfile(file_path: str):