feat: AI生图功能丰富

This commit is contained in:
2026-09-27 22:41:33 +08:00
parent 1c4fe1a836
commit 7f1503294f
20 changed files with 627 additions and 336 deletions
+22
View File
@@ -22,8 +22,10 @@ project_pnpm() {
BACKEND_PID=""
STUDIO_PID=""
WORKER_SUPERVISOR_PID=""
WORKER_SOURCE_WATCH_PID=""
COLLECTOR_WATCH_PID=""
COLLECTOR_STAMP=""
WORKER_SOURCE_STAMP=""
CLEANUP_DONE=false
stop_process_tree() {
@@ -44,8 +46,10 @@ cleanup() {
stop_process_tree "$BACKEND_PID"
stop_process_tree "$STUDIO_PID"
stop_process_tree "$WORKER_SUPERVISOR_PID"
stop_process_tree "$WORKER_SOURCE_WATCH_PID"
stop_process_tree "$COLLECTOR_WATCH_PID"
[[ -n "$COLLECTOR_STAMP" ]] && rm -f "$COLLECTOR_STAMP" 2>/dev/null
[[ -n "$WORKER_SOURCE_STAMP" ]] && rm -f "$WORKER_SOURCE_STAMP" 2>/dev/null
if [[ -f "$INSTANCE_PID_FILE" ]] && [[ "$(<"$INSTANCE_PID_FILE")" == "$$" ]]; then
rm -f "$INSTANCE_PID_FILE"
fi
@@ -189,6 +193,24 @@ supervise_worker &
WORKER_SUPERVISOR_PID=$!
echo "后台任务 Worker 守护进程已启动(PID: $WORKER_SUPERVISOR_PID)"
# Uvicorn 的热更新只管理 Web 进程;Worker 独立运行,代码更新后必须主动重启,
# 否则它会继续用内存中已导入的旧 generator.py 提交模型任务。
WORKER_SOURCE_STAMP="$(mktemp /tmp/osk-worker-source.XXXXXX)"
watch_worker_source() {
while true; do
sleep 2
if [[ -n "$(find server -type f \( -name '*.py' -o -name '*.yaml' \) -newer "$WORKER_SOURCE_STAMP" -print -quit 2>/dev/null)" ]]; then
touch "$WORKER_SOURCE_STAMP"
echo "🔧 检测到 Worker 源码改动,正在重启 Worker 以应用新版本…"
for worker_pid in $(pgrep -P "$WORKER_SUPERVISOR_PID" 2>/dev/null); do
kill -TERM "$worker_pid" 2>/dev/null || true
done
fi
done
}
watch_worker_source &
WORKER_SOURCE_WATCH_PID=$!
if ! command -v corepack >/dev/null 2>&1; then
echo "⚠️ 未找到 Corepack,本次跳过 studio 前端(可手动:corepack pnpm@${PNPM_VERSION} -C studio dev)"
# CI=true:node_modules 与 lockfile 不一致时自动重建,不弹确认