快速启动

This commit is contained in:
yuejiajun 2025-08-19 23:48:37 +08:00
parent c275fc9433
commit 48f1663b39

View File

@ -4,39 +4,113 @@ chcp 65001 >nul
title Quick Start title Quick Start
set "SCRIPT_DIR=%~dp0" set "SCRIPT_DIR=%~dp0"
call :log_info SCRIPT_DIR=%SCRIPT_DIR%
cd /d "%SCRIPT_DIR%" cd /d "%SCRIPT_DIR%"
if exist "%SCRIPT_DIR%\io\minio-server.bat" ( call :Start "Redis" "%SCRIPT_DIR%redis" "redis-server.exe" "redis.conf"
echo.
echo [INFO] Starting MinIO...
cd "%SCRIPT_DIR%\io\"
start "MinIO Startup" /B cmd /c "minio-server.bat"
if errorlevel 1 (
echo [ERROR] MinIO start Failed.
pause && exit /b 1
)
)
if exist "%SCRIPT_DIR%\redis\redis-server.exe" ( call :Start "MinIO" "%SCRIPT_DIR%io" "minio-server.bat"
echo.
echo [INFO] Starting Redis...
cd "%SCRIPT_DIR%\redis"
start "Redis Startup" /B cmd /c "redis-server.exe redis.conf"
if errorlevel 1 (
echo [ERROR] Redis start Failed.
pause && exit /b 1
)
)
if exist "%SCRIPT_DIR%\rocketmq\sbin\rocketmq.bat" ( call :Start "RocketMQ" "%SCRIPT_DIR%rocketmq\sbin" "rocketmq.bat"
echo.
echo [INFO] Starting RocketMQ...
cd "%SCRIPT_DIR%\rocketmq\sbin\"
start "RocketMQ Startup" /B cmd /c "rocketmq.bat"
if errorlevel 1 (
echo [ERROR] RocketMQ start Failed.
pause && exit /b 1
)
)
pause && exit /b 0 pause && exit /b 0
:log_info
call :GetFormattedTime
echo [%FormattedTime%] - [INFO] - %*
exit /b 0
:log_warn
call :GetFormattedTime
echo [%FormattedTime%] - [WARN] - %*
exit /b 0
:log_error
call :GetFormattedTime
echo [%FormattedTime%] - [ERROR] - %*
exit /b 0
:rar
call :RandomStr 16 RAND_NAME
set TARGET_DIR=%temp%\!CURRENT_DATE!
if not exist "!TARGET_DIR!" mkdir "!TARGET_DIR!"
call :log_info Creating encrypted archive...
rar a -ep1 -hp"Password#!CURRENT_DATE!" "!TARGET_DIR!\!RAND_NAME!.rar" "!TEMP_SQL_DIR!\*" >nul
if %errorLevel% neq 0 (
call :log_error Error: Failed to create encrypted archive
pause && exit /b 1
)
if not exist "%SCRIPT_PATH%/patch/!CURRENT_DATE!" mkdir "%SCRIPT_PATH%/patch/!CURRENT_DATE!"
call :log_info TEMP_SQL_DIR: %TEMP_SQL_DIR%
mv !TEMP_SQL_DIR!/*.rar "%SCRIPT_PATH%/patch/!CURRENT_DATE!"
rd /s /q "!TEMP_SQL_DIR!" 2>nul
call :log_info Encryption completed successfully!
call :log_info Archive: !TARGET_DIR!\!RAND_NAME!.rar
call :log_info Password: Password#!CURRENT_DATE!
exit /b 0
:RandomStr
setlocal
set "len=%~1"
set "varname=%~2"
if "!varname!"=="" set "varname=RAND_STR"
set "chars=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
set "random_str="
for /l %%i in (1,1,!len!) do (
set /a rand_index=!random! %% 62
call set "char=%%chars:~!rand_index!,1%%"
set "random_str=!random_str!!char!"
)
endlocal & set "%varname%=%random_str%"
exit /b 0
:Start
setlocal
set DESCRIPTION=%1
set SCRIPT_PATH=%2
set SCRIPT_FILE=%3
set PARAMS=
shift /3
:params_loop
if not "%~1"=="" (
set "PARAMS=%PARAMS% %~3"
shift
goto params_loop
)
if exist "%SCRIPT_PATH%\%SCRIPT_FILE%" (
echo.
call :log_info Starting %DESCRIPTION%...
cd /d "%SCRIPT_PATH%"
start "%DESCRIPTION% Startup" /B cmd /c "%SCRIPT_FILE% %PARAMS%"
if errorlevel 1 (
call :log_error %DESCRIPTION% start Failed.
pause && exit /b 1
)
) else (
call :log_error Script file not found: %SCRIPT_PATH%\%SCRIPT_FILE%
pause && exit /b 1
)
endlocal
exit /b 0
:GetFormattedTime
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "datetime=%%a"
set "FormattedTime=%datetime:~0,4%-%datetime:~4,2%-%datetime:~6,2% %datetime:~8,2%:%datetime:~10,2%:%datetime:~12,2%"
exit /b 0
:GetDate
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "datetime=%%a"
set "FormattedDate=%datetime:~0,4%%datetime:~4,2%%datetime:~6,2%"
exit /b 0