Files
qiniu-feishu-bot/deploy-windows.bat
编程专家 0d98013464 feat: 添加 Windows 专用部署脚本
- deploy-windows.bat: 一键部署脚本 (Node.js + PM2)
- docker-windows.bat: Docker 一键部署脚本
- manage-windows.bat: 服务管理工具 (启动/停止/日志/自启)
- check-env.bat: 环境检查工具
- uninstall.bat: 卸载清理工具
- WINDOWS_DEPLOY.md: Windows 部署完整文档
2026-03-25 08:23:50 +08:00

108 lines
2.4 KiB
Batchfile
Raw Permalink 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 七牛云上传 - 飞书机器人 Windows 部署
echo ========================================
echo.
REM 检查 Node.js
where node >nul 2>nul
if %errorlevel% neq 0 (
echo [错误] 未检测到 Node.js
echo 请先安装 Node.js v18+: https://nodejs.org/
pause
exit /b 1
)
for /f "tokens=2" %%i in ('node -v') do set NODE_VERSION=%%i
echo [✓] Node.js 版本:%NODE_VERSION%
REM 检查 npm
where npm >nul 2>nul
if %errorlevel% neq 0 (
echo [错误] 未检测到 npm
pause
exit /b 1
)
echo.
echo [步骤 1/5] 安装依赖...
call npm install
if %errorlevel% neq 0 (
echo [错误] 依赖安装失败
pause
exit /b 1
)
echo [✓] 依赖安装完成
echo.
echo [步骤 2/5] 配置环境变量...
if not exist .env (
copy .env.example .env
echo [✓] 已创建 .env 文件
echo.
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo [重要] 请编辑 .env 文件并填入配置信息
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo.
notepad .env
echo.
set /p CONTINUE="配置完成后按回车继续..."
) else (
echo [✓] .env 文件已存在
)
echo.
echo [步骤 3/5] 创建必要目录...
if not exist logs mkdir logs
if not exist config mkdir config
echo [✓] 目录创建完成
echo.
echo [步骤 4/5] 检查 PM2...
where pm2 >nul 2>nul
if %errorlevel% neq 0 (
echo [!] PM2 未安装,正在安装...
call npm install -g pm2
if %errorlevel% neq 0 (
echo [错误] PM2 安装失败,请以管理员身份运行此脚本
pause
exit /b 1
)
echo [✓] PM2 安装完成
) else (
echo [✓] PM2 已安装
)
echo.
echo [步骤 5/5] 启动服务...
call pm2 start pm2.config.cjs --name qiniu-bot
if %errorlevel% neq 0 (
echo [错误] 服务启动失败
pause
exit /b 1
)
echo.
echo ========================================
echo 部署成功!
echo ========================================
echo.
echo 服务状态查看pm2 logs qiniu-bot
echo 停止服务pm2 stop qiniu-bot
echo 重启服务pm2 restart qiniu-bot
echo.
REM 设置开机自启
echo [提示] 是否设置开机自启?(Y/N)
set /p AUTOSTART=
if /i "%AUTOSTART%"=="Y" (
echo.
echo [提示] 请以管理员身份运行以下命令设置开机自启:
echo pm2 startup
echo pm2 save
echo.
)
pause