Files
hair/local_test/start.sh
T
2026-07-16 22:57:12 +08:00

45 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# 启动发型补全服务
cd "$(dirname "$0")"
PID_FILE="hair_service.pid"
LOG_FILE="hair_service.log"
# 检查是否已在运行
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE")
if kill -0 "$PID" 2>/dev/null; then
echo "服务已在运行 (PID: $PID)"
exit 0
else
echo "清理无效的 PID 文件..."
rm "$PID_FILE"
fi
fi
# 检查 ComfyUI 是否运行
if ! curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8188/ >/dev/null 2>&1; then
echo "警告: ComfyUI 未运行 (http://127.0.0.1:8188)"
echo "请先启动 ComfyUI: python /home/ubuntu/ComfyUI/main.py --listen"
fi
# 启动服务
echo "启动发型补全服务..."
/home/ubuntu/ComfyUI/venv/bin/python app.py >> "$LOG_FILE" 2>&1 &
PID=$!
echo "$PID" > "$PID_FILE"
# 等待启动
sleep 2
if curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8899/ | grep -q "200"; then
echo "服务启动成功!"
echo "地址: http://127.0.0.1:8899"
echo "PID: $PID"
echo "日志: $LOG_FILE"
else
echo "服务启动失败,请检查日志: $LOG_FILE"
rm "$PID_FILE"
exit 1
fi