diff --git a/pm2.config.js b/pm2.config.js new file mode 100644 index 0000000..1890825 --- /dev/null +++ b/pm2.config.js @@ -0,0 +1,20 @@ +module.exports = { + apps : [{ + name: "frontend", + cwd: "./frontend", + script: "npm", + args: "start", + env: { + "PORT": 3000 + } + }, { + name: "backend", + cwd: "./backend", + script: "./.venv/bin/uvicorn", + args: "app.main:app --host 0.0.0.0 --port 8000", + interpreter: "none", + env: { + "PYTHONPATH": "." + } + }] +}; diff --git a/scripts/run.sh b/scripts/run.sh index 67783f6..4471658 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -62,6 +62,11 @@ cd frontend echo "--> Changed directory to $(pwd)" npm install echo "Frontend setup complete." + +# --- Frontend Production Build --- +echo "Building frontend for production..." +npm run build +echo "Frontend build complete." cd .. echo "--> Changed directory to $(pwd)" diff --git a/scripts/stop.sh b/scripts/stop.sh new file mode 100755 index 0000000..fb5c639 --- /dev/null +++ b/scripts/stop.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# 停止所有用 pm2 启动的服务,并清理进程 + +echo "Stopping all pm2 applications..." +pm2 stop all +echo "All pm2 applications stopped." + +echo "Deleting all pm2 processes..." +pm2 delete all +echo "All pm2 processes deleted."