46 lines
1.3 KiB
Batchfile
46 lines
1.3 KiB
Batchfile
@echo off
|
||
echo.
|
||
echo [检查] 正在检查数据库连接...
|
||
echo.
|
||
|
||
cd %~dp0
|
||
|
||
rem 配置
|
||
for /f "tokens=1,2 delims==" %%a in (config.ini) do (
|
||
if "%%a"=="DB_HOST" set DB_HOST=%%b
|
||
if "%%a"=="DB_PORT" set DB_PORT=%%b
|
||
if "%%a"=="REDIS_HOST" set REDIS_HOST=%%b
|
||
if "%%a"=="REDIS_PORT" set REDIS_PORT=%%b
|
||
)
|
||
|
||
cd ../ruoyi-admin/target
|
||
|
||
set JAVA_OPTS=-Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||
|
||
rem 检查DB
|
||
echo [检查] 正在检查数据库连接...
|
||
powershell -Command "$conn = New-Object System.Net.Sockets.TcpClient; $result = $conn.ConnectAsync('%DB_HOST%', %DB_PORT%).Wait(1000); if (!$result) { exit 1 } else { exit 0 }"
|
||
if %errorlevel% neq 0 (
|
||
echo [错误] Redis连接失败!请检查Redis IP: %REDIS_HOST%,端口: %REDIS_PORT%
|
||
goto end
|
||
)
|
||
echo [成功] 数据库连接正常
|
||
|
||
rem 链接Redis
|
||
echo [检查] 正在检查Redis连接....
|
||
powershell -Command "$conn = New-Object System.Net.Sockets.TcpClient; $result = $conn.ConnectAsync('%REDIS_HOST%', %REDIS_PORT%).Wait(1000); if (!$result) { exit 1 } else { exit 0 }"
|
||
if %errorlevel% neq 0 (
|
||
echo [错误] Redis连接失败!请检查Redis IP: %REDIS_HOST%,端口: %REDIS_PORT%
|
||
goto end
|
||
)
|
||
echo [成功] Redis连接正常
|
||
|
||
echo [信息] 所有服务检查完成,开始启动应用...
|
||
echo.
|
||
|
||
|
||
java -jar %JAVA_OPTS% ruoyi-admin.jar --spring.redis.host=%REDIS_HOST% --spring.redis.port=%REDIS_PORT%
|
||
|
||
:end
|
||
cd bin
|
||
pause |