mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-31 14:28:27 +08:00
(improvement)(assembly)Improve release scripts(bat) to make file structure cleaner. (#1007)
This commit is contained in:
@@ -1,118 +1,101 @@
|
||||
@echo off
|
||||
setlocal
|
||||
chcp 65001
|
||||
set "sbinDir=%~dp0"
|
||||
set "baseDir=%~dp0.."
|
||||
set "runtimeDir=%baseDir%\..\runtime"
|
||||
set "buildDir=%baseDir%\build"
|
||||
set "main_class=com.tencent.supersonic.StandaloneLauncher"
|
||||
set "python_path=python"
|
||||
set "pip_path=pip3"
|
||||
set "standalone_service=standalone"
|
||||
set "pyllm_service=pyllm"
|
||||
|
||||
set "javaRunDir=%runtimeDir%\supersonic-standalone"
|
||||
set "pythonRunDir=%runtimeDir%\supersonic-standalone\pyllm"
|
||||
call supersonic-common.bat %*
|
||||
|
||||
set "command=%~1"
|
||||
set "service=%~2"
|
||||
|
||||
if "%service%"=="" (
|
||||
set "service=%standalone_service%"
|
||||
)
|
||||
|
||||
set "model_name=%service%"
|
||||
IF "%service%"=="pyllm" (
|
||||
SET "llmProxy=PythonLLMProxy"
|
||||
set "llmProxy=PythonLLMProxy"
|
||||
set "model_name=%standalone_service%"
|
||||
)
|
||||
|
||||
call :BUILD_RUNTIME
|
||||
cd %baseDir%
|
||||
|
||||
if "%command%"=="restart" (
|
||||
call :STOP
|
||||
call :START
|
||||
call :stop
|
||||
call :start
|
||||
goto :EOF
|
||||
) else if "%command%"=="start" (
|
||||
call :START
|
||||
call :start
|
||||
goto :EOF
|
||||
) else if "%command%"=="stop" (
|
||||
call :STOP
|
||||
goto :EOF
|
||||
call :stop
|
||||
goto :EOF
|
||||
) else if "%command%"=="reload" (
|
||||
call :RELOAD_EXAMPLE
|
||||
goto :EOF
|
||||
call :reloadExamples
|
||||
goto :EOF
|
||||
) else (
|
||||
echo "Use command {start|stop|restart} to run."
|
||||
goto :EOF
|
||||
)
|
||||
|
||||
:START
|
||||
if "%service%"=="%pyllm_service%" (
|
||||
call :START_PYTHON
|
||||
call :START_JAVA
|
||||
|
||||
: start
|
||||
if "%service%"=="%pyllm_service%" (
|
||||
call :runPythonService
|
||||
call :runJavaService
|
||||
goto :EOF
|
||||
)
|
||||
call :START_JAVA
|
||||
goto :EOF
|
||||
|
||||
:STOP
|
||||
call :STOP_PYTHON
|
||||
call :STOP_JAVA
|
||||
goto :EOF
|
||||
|
||||
:START_PYTHON
|
||||
echo 'python service starting, see logs in pyllm/pyllm.log'
|
||||
cd "%pythonRunDir%"
|
||||
start /B %python_path% supersonic_pyllm.py > %pythonRunDir%\pyllm.log 2>&1
|
||||
timeout /t 10 >nul
|
||||
echo 'python service started'
|
||||
)
|
||||
call :runJavaService
|
||||
goto :EOF
|
||||
|
||||
:START_JAVA
|
||||
echo 'java service starting, see logs in logs/'
|
||||
cd "%javaRunDir%"
|
||||
if not exist "%runtimeDir%\supersonic-standalone\logs" mkdir "%runtimeDir%\supersonic-standalone\logs"
|
||||
set "libDir=%runtimeDir%\supersonic-standalone\lib"
|
||||
set "confDir=%runtimeDir%\supersonic-standalone\conf"
|
||||
set "webDir=%runtimeDir%\supersonic-standalone\webapp"
|
||||
set "classpath=%confDir%;%webDir%;%libDir%\*"
|
||||
|
||||
: stop
|
||||
call :stopPythonService
|
||||
call :stopJavaService
|
||||
goto :EOF
|
||||
|
||||
|
||||
: reloadExamples
|
||||
set "pythonRunDir=%baseDir%\pyllm"
|
||||
cd "%pythonRunDir%\sql"
|
||||
start %python_path% examples_reload_run.py
|
||||
goto :EOF
|
||||
|
||||
|
||||
: runJavaService
|
||||
echo 'java service starting, see logs in logs/'
|
||||
set "libDir=%baseDir%\lib"
|
||||
set "confDir=%baseDir%\conf"
|
||||
set "webDir=%baseDir%\webapp"
|
||||
set "logDir=%baseDir%\logs"
|
||||
set "classpath=%baseDir%;%webDir%;%libDir%\*;%confDir%"
|
||||
set "java-command=-Dfile.encoding=UTF-8 -Duser.language=Zh -Duser.region=CN -Duser.timezone=GMT+08 -Xms1024m -Xmx2048m -cp %CLASSPATH% %MAIN_CLASS%"
|
||||
if not exist %logDir% mkdir %logDir%
|
||||
start /B java %java-command% >nul 2>&1
|
||||
timeout /t 10 >nul
|
||||
echo 'java service started'
|
||||
goto :EOF
|
||||
|
||||
:STOP_PYTHON
|
||||
|
||||
: runPythonService
|
||||
echo 'python service starting, see logs in pyllm\pyllm.log'
|
||||
set "pythonRunDir=%baseDir%\pyllm"
|
||||
start /B %python_path% %pythonRunDir%\supersonic_pyllm.py > %pythonRunDir%\pyllm.log 2>&1
|
||||
timeout /t 10 >nul
|
||||
echo 'python service started'
|
||||
goto :EOF
|
||||
|
||||
|
||||
: stopPythonService
|
||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "python"') do (
|
||||
taskkill /PID %%i /F
|
||||
echo "python service (PID = %%i) is killed."
|
||||
)
|
||||
goto :EOF
|
||||
|
||||
:STOP_JAVA
|
||||
|
||||
: stopJavaService
|
||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "java"') do (
|
||||
taskkill /PID %%i /F
|
||||
echo "java service (PID = %%i) is killed."
|
||||
)
|
||||
goto :EOF
|
||||
|
||||
:RELOAD_EXAMPLE
|
||||
cd "%runtimeDir%\supersonic-standalone\pyllm\sql"
|
||||
start %python_path% examples_reload_run.py
|
||||
goto :EOF
|
||||
|
||||
:BUILD_RUNTIME
|
||||
rem 6. reset runtime
|
||||
if exist "%runtimeDir%" goto :EOF
|
||||
mkdir "%runtimeDir%"
|
||||
tar -zxvf "%buildDir%\supersonic-standalone.tar.gz" -C "%runtimeDir%"
|
||||
for /d %%f in ("%runtimeDir%\launchers-standalone-*") do (
|
||||
move "%%f" "%runtimeDir%\supersonic-standalone"
|
||||
)
|
||||
|
||||
rem 7. copy webapp to runtime
|
||||
tar -zxvf "%buildDir%\supersonic-webapp.tar.gz" -C "%buildDir%"
|
||||
if not exist "%runtimeDir%\supersonic-standalone\webapp" mkdir "%runtimeDir%\supersonic-standalone\webapp"
|
||||
xcopy /s /e /h /y "%buildDir%\supersonic-webapp\*" "%runtimeDir%\supersonic-standalone\webapp"
|
||||
if not exist "%runtimeDir%\supersonic-standalone\conf\webapp" mkdir "%runtimeDir%\supersonic-standalone\conf\webapp"
|
||||
xcopy /s /e /h /y "%runtimeDir%\supersonic-standalone\webapp\*" "%runtimeDir%\supersonic-standalone\conf\webapp"
|
||||
rd /s /q "%buildDir%\supersonic-webapp"
|
||||
endlocal
|
||||
Reference in New Issue
Block a user