32 lines
581 B
Bash
32 lines
581 B
Bash
#!/bin/bash
|
|
|
|
# 自动部署脚本
|
|
|
|
# 设置部署目录
|
|
DEPLOY_DIR="/root/online-slide"
|
|
|
|
# 切换到部署目录
|
|
cd "$DEPLOY_DIR" || exit 1
|
|
|
|
# 拉取最新代码(仓库是公开的,无需认证)
|
|
git pull origin main
|
|
|
|
|
|
npm config set registry https://registry.npmmirror.com
|
|
|
|
export PUPPETEER_SKIP_DOWNLOAD=1
|
|
|
|
# 安装依赖
|
|
npm install --verbose
|
|
|
|
# 启动服务
|
|
# 安装PM2(如果尚未安装)
|
|
npm install -g pm2
|
|
|
|
# 使用PM2启动服务,确保只有一个实例运行
|
|
pm2 start npm --name "online-slide" -- run web
|
|
# 保存PM2进程列表
|
|
pm2 save
|
|
|
|
echo "部署完成"
|