Files
NovelWriter_public/start_api.sh
NovelWriter 3f06328b96 Initial commit: NovelWriter public release
AI-powered novel generation tool with web UI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 10:26:43 +00:00

25 lines
812 B
Bash
Executable File
Raw Permalink 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/bash
# start_api.sh — 启动 NovelWriter FastAPI 后端
# 用法bash start_api.sh [--dev]
cd "$(dirname "$0")"
if [ "$1" = "--dev" ]; then
echo "=== 开发模式:后端 + 前端并行启动 ==="
uvicorn api_server:app --host 0.0.0.0 --port 7860 --reload &
BACKEND_PID=$!
echo "后端 PID: $BACKEND_PID (http://localhost:7860)"
cd frontend && npm run dev &
FRONTEND_PID=$!
echo "前端 PID: $FRONTEND_PID (http://localhost:3000)"
trap "kill $BACKEND_PID $FRONTEND_PID 2>/dev/null" EXIT INT TERM
wait
else
echo "=== 生产模式:构建前端 + 启动后端 ==="
if [ ! -d "frontend/dist" ]; then
echo "构建前端..."
cd frontend && npm install && npm run build && cd ..
fi
uvicorn api_server:app --host 0.0.0.0 --port 7860
fi