Files
ozon-seller-kit/start.command
T
2026-08-24 22:37:58 +08:00

57 lines
1.5 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.
#!/bin/zsh
# 双击本文件,或在终端执行:./start.command
cd "$(dirname "$0")"
if [[ ! -d .venv ]]; then
echo "未找到 .venv,正在创建并安装依赖…"
python3 -m venv .venv || exit 1
source .venv/bin/activate
pip install -r server/requirements.txt || exit 1
else
source .venv/bin/activate
fi
if [[ ! -f .env ]]; then
echo "未找到 .env,已从 .env.example 复制,请填入 DEEPSEEK_API_KEY 后再启动。"
cp .env.example .env
echo "按回车关闭…"
read -r
exit 1
fi
# studio 依赖检查(node_modules 不存在时安装)
if [[ -d studio ]] && [[ ! -d studio/node_modules ]]; then
echo "未找到 studio/node_modules,正在安装依赖…"
(cd studio && pnpm install) || exit 1
fi
# 后台启动 studioVite8900 端口,/api 代理到 8800
STUDIO_PID=""
if [[ -d studio ]]; then
(cd studio && pnpm dev) &
STUDIO_PID=$!
echo "studio 已后台启动:http://127.0.0.1:8900/"
fi
# Ctrl-C / 退出时把 studio 一起停掉
cleanup() {
if [[ -n "$STUDIO_PID" ]]; then
echo "正在停止 studio…"
kill "$STUDIO_PID" 2>/dev/null
fi
}
trap cleanup EXIT INT TERM
echo
echo "后端启动中:http://127.0.0.1:8800/ozonSeller.html"
echo "studio 启动中:http://127.0.0.1:8900/"
echo "按 Ctrl+C 可停止全部服务"
echo
# --app-dir server 让 uvicorn 在 server/ 下找 main:app,工作目录仍是仓库根(.env 在此)
uvicorn main:app --app-dir server --reload --reload-include '*.yaml' --host 127.0.0.1 --port 8800
echo
echo "服务已停止。按回车关闭窗口…"
read -r