Files
Web_BLS_Heartbeat_Server/scripts/update.bat
XuJiacheng 625cb9eea4 feat: 添加部署脚本和文档并优化Kafka消费者配置
- 添加部署相关脚本(deploy.bat/update.bat/package.bat)和文档(deployment.md/package-guide.md)
 - 新增PM2配置文件(ecosystem.config.js/ecosystem.config.cjs)
 - 优化Kafka消费者配置支持动态fromOffset
 - 添加环境检查脚本(check-env.js)
 - 更新.gitignore添加release目录
 - 补充.env.example配置文件
2026-01-16 16:19:31 +08:00

91 lines
2.2 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
chcp 65001 >nul
echo ========================================
echo BLS心跳接收端更新脚本
echo ========================================
setlocal enabledelayedexpansion
:: 检查服务是否运行
echo [1/6] 检查服务状态...
pm2 describe web-bls-heartbeat-server >nul 2>&1
if errorlevel 1 (
echo [警告] 服务未运行,跳过停止步骤
) else (
echo [信息] 停止服务...
pm2 stop web-bls-heartbeat-server
if errorlevel 1 (
echo [错误] 服务停止失败
pause
exit /b 1
)
)
:: 备份当前版本
echo [2/6] 备份当前版本...
if exist "dist" (
if exist "dist_backup" (
rmdir /s /q dist_backup
)
xcopy /E /I /Y dist dist_backup >nul
echo [成功] 当前版本已备份到dist_backup目录
) else (
echo [警告] 未找到dist目录跳过备份
)
:: 更新依赖
echo [3/6] 更新项目依赖...
call npm install --production
if errorlevel 1 (
echo [错误] 依赖更新失败
pause
exit /b 1
)
:: 检查构建文件
echo [4/6] 检查构建文件...
if not exist "dist\index.es.js" (
echo [错误] 未找到构建文件请确保已上传新版本的dist目录
pause
exit /b 1
)
echo [成功] 构建文件检查通过
:: 更新数据库(如果需要)
echo [5/6] 更新数据库...
echo [信息] 运行数据库更新脚本...
call npm run db:apply
if errorlevel 1 (
echo [警告] 数据库更新失败,请检查数据库连接配置
echo [提示] 可以稍后手动运行: npm run db:apply
) else (
echo [成功] 数据库更新完成
)
:: 启动服务
echo [6/6] 启动服务...
pm2 start ecosystem.config.cjs
if errorlevel 1 (
echo [错误] 服务启动失败
pause
exit /b 1
)
:: 显示服务状态
echo ========================================
echo 服务状态
echo ========================================
pm2 status
echo ========================================
echo 更新完成!
echo ========================================
echo.
echo 常用命令:
echo 查看状态: pm2 status
echo 查看日志: pm2 logs web-bls-heartbeat-server
echo 重启服务: pm2 restart web-bls-heartbeat-server
echo 停止服务: pm2 stop web-bls-heartbeat-server
echo 实时监控: pm2 monit
echo.
pause