Browse Source

Refactor deployment scripts to install backend dependencies separately and update build commands. Remove frontend access URL from deployment output.

deploy
dash 2 weeks ago
parent
commit
3fb6d4310a
  1. 8
      deploy.ps1
  2. 14
      deploy.sh
  3. 19
      ecosystem.config.js

8
deploy.ps1

@ -34,11 +34,14 @@ Write-Host "✅ PM2 已安装" -ForegroundColor Green
# 4. 安装依赖
Write-Host "`n📦 安装项目依赖..." -ForegroundColor Blue
pnpm install:all
pnpm install
Set-Location backend
pnpm install
Set-Location ..
# 5. 构建项目
Write-Host "`n🔨 构建项目..." -ForegroundColor Blue
pnpm build
pnpm build:backend
# 6. 创建生产环境配置
Write-Host "`n⚙️ 创建生产环境配置..." -ForegroundColor Blue
@ -82,7 +85,6 @@ pm2 status
Write-Host "`n🎉 部署成功!" -ForegroundColor Green
Write-Host "`n访问地址:" -ForegroundColor Cyan
Write-Host " - 前端: http://localhost:5500" -ForegroundColor White
Write-Host " - 后端: http://localhost:3000" -ForegroundColor White
Write-Host "`n常用命令:" -ForegroundColor Cyan
Write-Host " pm2 status # 查看服务状态" -ForegroundColor White

14
deploy.sh

@ -66,7 +66,8 @@ echo -e "${GREEN}✅ 编译工具已就绪${NC}"
# 4. 安装依赖
echo -e "${BLUE}📦 安装项目依赖...${NC}"
pnpm install:all
pnpm install
cd backend && pnpm install && cd ..
# 4.5. 强制重建 sqlite3(确保原生模块正确编译)
echo -e "${BLUE}🔨 重建 sqlite3 原生模块...${NC}"
@ -78,12 +79,19 @@ rm -rf node_modules/sqlite3 2>/dev/null || true
pnpm install sqlite3 --force
# 重建以确保原生模块正确编译
npm rebuild sqlite3
# 删除 bcrypt 模块并重新安装,确保在当前平台编译
rm -rf node_modules/.pnpm/bcrypt@* 2>/dev/null || true
rm -rf node_modules/bcrypt 2>/dev/null || true
# 强制重新安装 bcrypt
pnpm install bcrypt --force
# 重建以确保原生模块正确编译
npm rebuild bcrypt
cd ..
echo -e "${GREEN}✅ sqlite3 重建完成${NC}"
echo -e "${GREEN}bcrypt 重建完成${NC}"
# 5. 构建项目
echo -e "${BLUE}🔨 构建项目...${NC}"
pnpm build
pnpm build:backend
# 6. 创建生产环境配置
echo -e "${BLUE}⚙️ 创建生产环境配置...${NC}"

19
ecosystem.config.js

@ -29,24 +29,7 @@ module.exports = {
// 启动延迟
listen_timeout: 3000,
kill_timeout: 5000
},
// {
// name: 'just-demo-frontend',
// script: 'npx',
// cwd: path.resolve(__dirname),
// args: 'serve frontend/dist -p 5500 -s',
// instances: 1,
// autorestart: true,
// watch: false,
// max_memory_restart: '200M',
// env: {
// NODE_ENV: 'production'
// },
// error_file: path.resolve(__dirname, 'logs/frontend-error.log'),
// out_file: path.resolve(__dirname, 'logs/frontend-out.log'),
// log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
// merge_logs: true
// }
}
]
};

Loading…
Cancel
Save