feat: K线点位标注工具完整实现与Ubuntu PM2部署
纯前端 Canvas 画线、拖拽、导出;Python venv + PM2 静态服务; 含部署脚本与使用/部署文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# K线点位标注工具 - Ubuntu 一键部署脚本
|
||||
# 用法: sudo bash deploy/install.sh
|
||||
# 部署目录: /opt/chart-label-tool
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
APP_DIR="/opt/chart-label-tool"
|
||||
REPO_URL="https://git.bz121.com/dekun/chart-label-tool.git"
|
||||
PORT=8080
|
||||
SERVICE_USER="root"
|
||||
|
||||
echo "==> K线点位标注工具 部署开始"
|
||||
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
echo "请使用 root 运行: sudo bash deploy/install.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 依赖
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq git python3 python3-venv python3-pip curl
|
||||
|
||||
# Node.js + PM2(若未安装)
|
||||
if ! command -v pm2 &>/dev/null; then
|
||||
if ! command -v node &>/dev/null; then
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||
apt-get install -y -qq nodejs
|
||||
fi
|
||||
npm install -g pm2
|
||||
fi
|
||||
|
||||
# 拉取代码
|
||||
if [[ -d "$APP_DIR/.git" ]]; then
|
||||
echo "==> 更新已有仓库 $APP_DIR"
|
||||
cd "$APP_DIR"
|
||||
git pull --ff-only origin main || git pull --ff-only
|
||||
else
|
||||
echo "==> 克隆仓库到 $APP_DIR"
|
||||
git clone "$REPO_URL" "$APP_DIR"
|
||||
cd "$APP_DIR"
|
||||
fi
|
||||
|
||||
# Python 虚拟环境
|
||||
if [[ ! -d "$APP_DIR/venv" ]]; then
|
||||
echo "==> 创建 Python 虚拟环境"
|
||||
python3 -m venv "$APP_DIR/venv"
|
||||
fi
|
||||
|
||||
# PM2 启动/重载
|
||||
echo "==> 配置 PM2 守护进程"
|
||||
pm2 delete chart-label-tool 2>/dev/null || true
|
||||
pm2 start "$APP_DIR/deploy/ecosystem.config.cjs"
|
||||
pm2 save
|
||||
pm2 startup systemd -u "$SERVICE_USER" --hp "/root" 2>/dev/null || pm2 startup
|
||||
|
||||
# 防火墙提示(可选)
|
||||
if command -v ufw &>/dev/null && ufw status | grep -q "Status: active"; then
|
||||
ufw allow "$PORT/tcp" 2>/dev/null || true
|
||||
echo "==> 已尝试放行 UFW 端口 $PORT"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " 部署完成"
|
||||
echo " 访问地址: http://<服务器局域网IP>:$PORT"
|
||||
echo " 应用目录: $APP_DIR"
|
||||
echo " 查看状态: pm2 status"
|
||||
echo " 查看日志: pm2 logs chart-label-tool"
|
||||
echo "=========================================="
|
||||
Reference in New Issue
Block a user