mirror of
https://github.com/zhinianboke/xianyu-auto-reply.git
synced 2025-08-29 17:17:38 +08:00
新增windows部署
This commit is contained in:
parent
1c2cd1bce8
commit
c8045da0b0
57
README.md
57
README.md
@ -117,7 +117,8 @@ xianyu-auto-reply/
|
||||
├── 🐳 Docker部署
|
||||
│ ├── Dockerfile # Docker镜像构建文件
|
||||
│ ├── docker-compose.yml # Docker Compose一键部署配置
|
||||
│ └── docker-deploy.sh # Docker部署管理脚本
|
||||
│ ├── docker-deploy.sh # Docker部署管理脚本(Linux/macOS)
|
||||
│ └── docker-deploy.bat # Docker部署管理脚本(Windows)
|
||||
├── 📋 配置文件
|
||||
│ ├── global_config.yml # 全局配置文件(WebSocket、API等)
|
||||
│ ├── requirements.txt # Python依赖包列表
|
||||
@ -143,13 +144,28 @@ xianyu-auto-reply/
|
||||
git clone https://github.com/zhinianboke/xianyu-auto-reply.git
|
||||
cd xianyu-auto-reply
|
||||
|
||||
# 2. 一键部署(自动构建镜像)
|
||||
# 2. 设置脚本执行权限(Linux/macOS)
|
||||
chmod +x docker-deploy.sh
|
||||
|
||||
# 3. 一键部署(自动构建镜像)
|
||||
./docker-deploy.sh
|
||||
|
||||
# 3. 访问系统
|
||||
# 4. 访问系统
|
||||
# http://localhost:8080
|
||||
```
|
||||
|
||||
**Windows用户**:
|
||||
```cmd
|
||||
# 使用Windows批处理脚本(推荐)
|
||||
docker-deploy.bat
|
||||
|
||||
# 或者使用Git Bash/WSL
|
||||
bash docker-deploy.sh
|
||||
|
||||
# 或者直接使用Docker Compose
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
### 方式二:Docker Compose 手动部署
|
||||
|
||||
```bash
|
||||
@ -475,6 +491,41 @@ python Start.py
|
||||
- 提交 Pull Request
|
||||
|
||||
|
||||
## ❓ 常见问题
|
||||
|
||||
### 1. 端口被占用
|
||||
如果8080端口被占用,可以修改 `.env` 文件中的 `WEB_PORT` 配置。
|
||||
|
||||
### 2. 数据库连接失败
|
||||
检查数据库文件权限,确保应用有读写权限。
|
||||
|
||||
### 3. WebSocket连接失败
|
||||
检查防火墙设置,确保WebSocket端口可以访问。
|
||||
|
||||
### 4. Shell脚本执行错误(Linux/macOS)
|
||||
如果遇到 `bad interpreter` 错误,说明脚本的行结束符格式不正确:
|
||||
|
||||
```bash
|
||||
# 方法1:手动修复行结束符
|
||||
sed -i 's/\r$//' docker-deploy.sh
|
||||
chmod +x docker-deploy.sh
|
||||
./docker-deploy.sh
|
||||
|
||||
# 方法2:直接使用bash运行
|
||||
bash docker-deploy.sh
|
||||
```
|
||||
|
||||
### 5. Windows系统部署
|
||||
Windows用户推荐使用批处理脚本:
|
||||
|
||||
```cmd
|
||||
# 使用Windows批处理脚本
|
||||
docker-deploy.bat
|
||||
|
||||
# 或者使用PowerShell
|
||||
powershell -ExecutionPolicy Bypass -File docker-deploy.bat
|
||||
```
|
||||
|
||||
## 📞 技术支持
|
||||
|
||||
|
||||
|
217
docker-deploy.bat
Normal file
217
docker-deploy.bat
Normal file
@ -0,0 +1,217 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM 闲鱼自动回复系统 Docker 部署脚本 (Windows版本)
|
||||
REM 支持快速部署和管理
|
||||
|
||||
title 闲鱼自动回复系统 Docker 部署
|
||||
|
||||
REM 项目配置
|
||||
set PROJECT_NAME=xianyu-auto-reply
|
||||
set COMPOSE_FILE=docker-compose.yml
|
||||
set ENV_FILE=.env
|
||||
|
||||
REM 颜色定义(Windows CMD不支持ANSI颜色,使用echo代替)
|
||||
set "INFO_PREFIX=[INFO]"
|
||||
set "SUCCESS_PREFIX=[SUCCESS]"
|
||||
set "WARNING_PREFIX=[WARNING]"
|
||||
set "ERROR_PREFIX=[ERROR]"
|
||||
|
||||
REM 检查依赖
|
||||
echo %INFO_PREFIX% 检查系统依赖...
|
||||
|
||||
where docker >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
echo %ERROR_PREFIX% Docker 未安装,请先安装 Docker Desktop
|
||||
echo 下载地址: https://www.docker.com/products/docker-desktop
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
where docker-compose >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
echo %ERROR_PREFIX% Docker Compose 未安装,请先安装 Docker Compose
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo %SUCCESS_PREFIX% 系统依赖检查通过
|
||||
|
||||
REM 初始化配置
|
||||
echo %INFO_PREFIX% 初始化配置文件...
|
||||
|
||||
if not exist "%ENV_FILE%" (
|
||||
echo %WARNING_PREFIX% %ENV_FILE% 文件不存在,将使用默认配置
|
||||
echo %INFO_PREFIX% 如需自定义配置,请创建 %ENV_FILE% 文件
|
||||
) else (
|
||||
echo %SUCCESS_PREFIX% %ENV_FILE% 配置文件已存在
|
||||
)
|
||||
|
||||
REM 创建必要的目录
|
||||
if not exist "data" mkdir data
|
||||
if not exist "logs" mkdir logs
|
||||
if not exist "backups" mkdir backups
|
||||
if not exist "static\uploads\images" mkdir static\uploads\images
|
||||
echo %SUCCESS_PREFIX% 已创建必要的目录
|
||||
|
||||
REM 处理命令行参数
|
||||
if "%1"=="" goto quick_deploy
|
||||
if "%1"=="help" goto show_help
|
||||
if "%1"=="start" goto start_services
|
||||
if "%1"=="stop" goto stop_services
|
||||
if "%1"=="restart" goto restart_services
|
||||
if "%1"=="status" goto show_status
|
||||
if "%1"=="logs" goto show_logs
|
||||
if "%1"=="build" goto build_image
|
||||
if "%1"=="cleanup" goto cleanup
|
||||
goto unknown_command
|
||||
|
||||
:quick_deploy
|
||||
echo %INFO_PREFIX% 快速部署模式
|
||||
goto build_and_start
|
||||
|
||||
:build_image
|
||||
echo %INFO_PREFIX% 构建 Docker 镜像...
|
||||
set /p use_cn="是否使用国内镜像源?(y/n): "
|
||||
if /i "!use_cn!"=="y" (
|
||||
docker-compose -f docker-compose-cn.yml build --no-cache
|
||||
) else (
|
||||
docker-compose build --no-cache
|
||||
)
|
||||
if %errorlevel% neq 0 (
|
||||
echo %ERROR_PREFIX% 镜像构建失败
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo %SUCCESS_PREFIX% 镜像构建完成
|
||||
goto end
|
||||
|
||||
:build_and_start
|
||||
call :build_image
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
|
||||
:start_services
|
||||
echo %INFO_PREFIX% 启动服务...
|
||||
docker-compose up -d
|
||||
if %errorlevel% neq 0 (
|
||||
echo %ERROR_PREFIX% 服务启动失败
|
||||
docker-compose logs
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo %SUCCESS_PREFIX% 服务启动完成
|
||||
|
||||
REM 等待服务就绪
|
||||
echo %INFO_PREFIX% 等待服务就绪...
|
||||
timeout /t 10 /nobreak >nul
|
||||
|
||||
REM 检查服务状态
|
||||
docker-compose ps | findstr "Up" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo %SUCCESS_PREFIX% 服务运行正常
|
||||
call :show_access_info
|
||||
) else (
|
||||
echo %ERROR_PREFIX% 服务启动失败
|
||||
docker-compose logs
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
goto end
|
||||
|
||||
:stop_services
|
||||
echo %INFO_PREFIX% 停止服务...
|
||||
docker-compose down
|
||||
echo %SUCCESS_PREFIX% 服务已停止
|
||||
goto end
|
||||
|
||||
:restart_services
|
||||
echo %INFO_PREFIX% 重启服务...
|
||||
docker-compose restart
|
||||
echo %SUCCESS_PREFIX% 服务已重启
|
||||
goto end
|
||||
|
||||
:show_status
|
||||
echo %INFO_PREFIX% 服务状态:
|
||||
docker-compose ps
|
||||
echo.
|
||||
echo %INFO_PREFIX% 资源使用:
|
||||
for /f "tokens=*" %%i in ('docker-compose ps -q') do (
|
||||
docker stats --no-stream %%i
|
||||
)
|
||||
goto end
|
||||
|
||||
:show_logs
|
||||
if "%2"=="" (
|
||||
docker-compose logs -f
|
||||
) else (
|
||||
docker-compose logs -f %2
|
||||
)
|
||||
goto end
|
||||
|
||||
:cleanup
|
||||
echo %WARNING_PREFIX% 这将删除所有容器、镜像和数据,确定要继续吗?
|
||||
set /p confirm="请输入 y 确认: "
|
||||
if /i "!confirm!"=="y" (
|
||||
echo %INFO_PREFIX% 清理环境...
|
||||
docker-compose down -v --rmi all
|
||||
rmdir /s /q data logs backups 2>nul
|
||||
echo %SUCCESS_PREFIX% 环境清理完成
|
||||
) else (
|
||||
echo %INFO_PREFIX% 取消清理操作
|
||||
)
|
||||
goto end
|
||||
|
||||
:show_access_info
|
||||
echo.
|
||||
echo %SUCCESS_PREFIX% 🎉 部署完成!
|
||||
echo.
|
||||
echo 📱 访问地址:
|
||||
echo HTTP: http://localhost:8080
|
||||
echo.
|
||||
echo 🔐 默认登录信息:
|
||||
echo 用户名: admin
|
||||
echo 密码: admin123
|
||||
echo.
|
||||
echo 📊 管理命令:
|
||||
echo 查看状态: %~nx0 status
|
||||
echo 查看日志: %~nx0 logs
|
||||
echo 重启服务: %~nx0 restart
|
||||
echo 停止服务: %~nx0 stop
|
||||
echo.
|
||||
goto :eof
|
||||
|
||||
:show_help
|
||||
echo 闲鱼自动回复系统 Docker 部署脚本 (Windows版本)
|
||||
echo.
|
||||
echo 用法: %~nx0 [命令]
|
||||
echo.
|
||||
echo 命令:
|
||||
echo start 启动服务
|
||||
echo stop 停止服务
|
||||
echo restart 重启服务
|
||||
echo status 查看服务状态
|
||||
echo logs 查看日志
|
||||
echo build 构建镜像
|
||||
echo cleanup 清理环境
|
||||
echo help 显示帮助信息
|
||||
echo.
|
||||
echo 示例:
|
||||
echo %~nx0 # 快速部署
|
||||
echo %~nx0 start # 启动服务
|
||||
echo %~nx0 logs # 查看日志
|
||||
echo.
|
||||
goto end
|
||||
|
||||
:unknown_command
|
||||
echo %ERROR_PREFIX% 未知命令: %1
|
||||
call :show_help
|
||||
exit /b 1
|
||||
|
||||
:end
|
||||
if "%1"=="" (
|
||||
echo.
|
||||
echo 按任意键退出...
|
||||
pause >nul
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user