Files
hair/run_worker.sh
T
xslandClaude Opus 4.8 a177dc2583 去除上传图片的分辨率与文件大小限制
- app.py: 删除全部 MAX_FILE_BYTES(≤1MB→1006) 与 MIN_SHORT_SIDE/MIN_LONG_SIDE
  (分辨率→1002) 校验及对应常量; 同步清理 File 描述、图片要求说明、
  错误码表(移除1002/1006)与过时示例
- gateway/app.py: 删除注释掉的 1006 大小校验块与描述里的 ≤1MB
- run_worker.sh / hair-worker.service: 删除临时放开限制的环境变量
- tests: 移除已过时的 test_oversize_1006 / test_lowres_1002 及 oversize_file fixture

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 22:21:39 +08:00

48 lines
1.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 启动 GPU worker(接口1 四庭七眼 / 接口2 发际线等)。
# 默认:后台运行,绑定 0.0.0.0:8187,日志写到 worker.logPID 写到 worker.pid。
# 每次开机手动执行一次即可。停止用 ./stop_worker.sh。
#
# 可用环境变量覆盖:
# HOST=127.0.0.1 PORT=9000 ./run_worker.sh
# FOREGROUND=1 ./run_worker.sh # 前台运行(调试用,Ctrl+C 退出)
#
# 鉴权密码读 worker_config.json 的 accept_passwords
# 也可用 WORKER_ACCEPT_PASSWORDS=逗号分隔 覆盖。
set -euo pipefail
cd "$(dirname "$0")"
VENV_UVICORN="./venv/bin/uvicorn"
PID_FILE="worker.pid"
LOG_FILE="worker.log"
HOST="${HOST:-0.0.0.0}"
PORT="${PORT:-8187}"
if [ ! -x "$VENV_UVICORN" ]; then
echo "找不到 $VENV_UVICORN,请先创建 venv 并安装依赖(见 requirements.txt" >&2
exit 1
fi
# 已在运行则不重复启动
if [ -f "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
echo "worker 已在运行 (PID $(cat "$PID_FILE")),端口 ${PORT}。如需重启请先 ./stop_worker.sh" >&2
exit 0
fi
if [ "${FOREGROUND:-0}" = "1" ]; then
echo ">> 前台运行 worker: ${HOST}:${PORT}"
exec "$VENV_UVICORN" app:app --host "$HOST" --port "$PORT"
fi
echo ">> 后台启动 worker: ${HOST}:${PORT}"
nohup "$VENV_UVICORN" app:app --host "$HOST" --port "$PORT" >> "$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
sleep 1
if kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
echo ">> 已启动,PID $(cat "$PID_FILE"),日志:$LOG_FILE"
else
echo ">> 启动失败,请查看 $LOG_FILE" >&2
rm -f "$PID_FILE"
exit 1
fi