diff --git a/deploy.sh b/deploy.sh index 2f4042b..596dbca 100644 --- a/deploy.sh +++ b/deploy.sh @@ -1,7 +1,6 @@ #!/bin/bash # 自动部署脚本 -# 每天定时从 Gitea 拉取最新代码并执行构建 # 设置部署目录 DEPLOY_DIR="/root/online-slide" @@ -12,10 +11,21 @@ cd "$DEPLOY_DIR" || exit 1 # 拉取最新代码(仓库是公开的,无需认证) git pull origin main -# 安装依赖(如果需要) -npm install -# 执行构建 -npm run build +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 "部署完成" diff --git a/package.json b/package.json index b1b32fc..be6dbfa 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "test": "gulp test", "start": "gulp serve", + "web": "gulp serve --host 0.0.0.0 --port 3000", "build": "gulp build" }, "repository": {