e797d188ee
Add Express gateway, ecosystem config, and one-click install with native PostgreSQL, Node, and Python venv on port 23566. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
861 B
Bash
40 lines
861 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
INSTALL_DIR="${INSTALL_DIR:-/opt/secondary-school-grade-archive}"
|
|
BRANCH="${BRANCH:-main}"
|
|
|
|
GREEN='\033[0;32m'
|
|
NC='\033[0m'
|
|
log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
|
|
|
|
cd "${INSTALL_DIR}" || exit 1
|
|
find "${INSTALL_DIR}" -name "*.sh" -exec sed -i 's/\r$//' {} +
|
|
|
|
log_info "拉取最新代码…"
|
|
git fetch origin
|
|
git checkout "${BRANCH}" 2>/dev/null || true
|
|
git pull origin "${BRANCH}"
|
|
|
|
log_info "更新后端依赖…"
|
|
cd backend
|
|
source venv/bin/activate
|
|
pip install -r requirements.txt -q
|
|
deactivate
|
|
|
|
log_info "重建前端…"
|
|
cd ../frontend
|
|
npm ci --silent
|
|
npm run build
|
|
|
|
log_info "更新网关…"
|
|
cd ../deploy/pm2
|
|
npm ci --silent
|
|
|
|
log_info "重启 PM2…"
|
|
cd "${INSTALL_DIR}"
|
|
pm2 reload deploy/pm2/ecosystem.config.cjs --update-env || pm2 start deploy/pm2/ecosystem.config.cjs
|
|
pm2 save
|
|
|
|
log_info "更新完成"
|