mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 13:47:09 +00:00
(improvement)(script) update bat script (#163)
* (improvement)(script) update bat script --------- Co-authored-by: jolunoluo
This commit is contained in:
@@ -1,28 +1,50 @@
|
|||||||
@echo off
|
@echo off
|
||||||
setlocal
|
setlocal
|
||||||
|
chcp 65001
|
||||||
set "sbinDir=%~dp0"
|
set "sbinDir=%~dp0"
|
||||||
set "baseDir=%~dp0.."
|
set "baseDir=%~dp0.."
|
||||||
set "buildDir=%baseDir%\build"
|
set "buildDir=%baseDir%\build"
|
||||||
|
set "runtimeDir=%baseDir%\..\runtime"
|
||||||
|
set "pip_path=pip3"
|
||||||
|
|
||||||
|
rem 1. build backend java modules
|
||||||
rem 1. build semantic chat service
|
|
||||||
del /q "%buildDir%\*.tar.gz" 2>NUL
|
del /q "%buildDir%\*.tar.gz" 2>NUL
|
||||||
|
|
||||||
call mvn -f "%baseDir%\..\pom.xml" clean package -DskipTests
|
call mvn -f "%baseDir%\..\pom.xml" clean package -DskipTests
|
||||||
|
|
||||||
rem 2. move package to build
|
rem 2. move package to build
|
||||||
echo f|xcopy "%baseDir%\..\launchers\standalone\target\*.tar.gz" "%buildDir%\supersonic.tar.gz"
|
echo f|xcopy "%baseDir%\..\launchers\standalone\target\*.tar.gz" "%buildDir%\supersonic-standalone.tar.gz"
|
||||||
|
|
||||||
rem 3. build webapp
|
rem 3. build frontend webapp
|
||||||
cd "%baseDir%\..\webapp"
|
cd "%baseDir%\..\webapp"
|
||||||
call start-fe-prod.bat
|
call start-fe-prod.bat
|
||||||
copy /y "%baseDir%\..\webapp\supersonic-webapp.tar.gz" "%buildDir%\"
|
copy /y "%baseDir%\..\webapp\supersonic-webapp.tar.gz" "%buildDir%\"
|
||||||
|
|
||||||
|
rem 4. copy webapp to java classpath
|
||||||
cd "%buildDir%"
|
cd "%buildDir%"
|
||||||
tar -zxvf supersonic-webapp.tar.gz
|
tar -zxvf supersonic-webapp.tar.gz
|
||||||
move supersonic-webapp webapp
|
move supersonic-webapp webapp
|
||||||
move webapp ..\..\launchers\standalone\target\classes
|
move webapp ..\..\launchers\standalone\target\classes
|
||||||
|
|
||||||
|
rem 5. build backend python modules
|
||||||
|
echo "start installing python modules with pip: ${pip_path}"
|
||||||
|
set requirementPath="%baseDir%/../chat/core/src/main/python/requirements.txt"
|
||||||
|
%pip_path% install -r %requirementPath%
|
||||||
|
echo "install python modules success"
|
||||||
|
|
||||||
|
rem 6. reset runtime
|
||||||
|
rd /s /q "%runtimeDir%"
|
||||||
|
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
|
endlocal
|
||||||
@@ -1,120 +1,87 @@
|
|||||||
@echo off
|
@echo off
|
||||||
setlocal
|
setlocal
|
||||||
|
chcp 65001
|
||||||
set "sbinDir=%~dp0"
|
set "sbinDir=%~dp0"
|
||||||
set "baseDir=%~dp0.."
|
set "baseDir=%~dp0.."
|
||||||
set "runtimeDir=%baseDir%\..\runtime"
|
set "runtimeDir=%baseDir%\..\runtime"
|
||||||
set "buildDir=%baseDir%\build"
|
set "buildDir=%baseDir%\build"
|
||||||
|
set "main_class=com.tencent.supersonic.StandaloneLauncher"
|
||||||
set "command=%~1"
|
|
||||||
set "module=%~2"
|
|
||||||
|
|
||||||
set "APP_NAME=standalone-service"
|
|
||||||
set "MAIN_CLASS=com.tencent.supersonic.StandaloneLauncher"
|
|
||||||
|
|
||||||
set "python_path=python"
|
set "python_path=python"
|
||||||
set "pip_path=pip3"
|
set "pip_path=pip3"
|
||||||
set "llm_host=127.0.0.1"
|
set "standalone_service=standalone"
|
||||||
set "llm_port=9092"
|
set "llmparser_service=llmparser"
|
||||||
set "start_name=api_service"
|
|
||||||
|
|
||||||
|
set "javaRunDir=%runtimeDir%\supersonic-standalone"
|
||||||
|
set "pythonRunDir=%runtimeDir%\supersonic-standalone\llmparser"
|
||||||
|
|
||||||
if "%module%"=="" (
|
set "command=%~1"
|
||||||
set "module=standalone"
|
set "service=%~2"
|
||||||
) else if "%module%"=="semantic" (
|
|
||||||
set "APP_NAME=semantic-service"
|
|
||||||
set "MAIN_CLASS=com.tencent.supersonic.SemanticLauncher"
|
|
||||||
) else if "%module%"=="chat" (
|
|
||||||
set "APP_NAME=chat-service"
|
|
||||||
set "MAIN_CLASS=com.tencent.supersonic.ChatLauncher"
|
|
||||||
)
|
|
||||||
|
|
||||||
if "%command%"=="" (
|
if "%service%"=="" (
|
||||||
set "command=restart"
|
set "service=%standalone_service%"
|
||||||
)
|
|
||||||
|
|
||||||
set "libDir=%runtimeDir%\supersonic-%module%\lib"
|
|
||||||
set "confDir=%runtimeDir%\supersonic-%module%\conf"
|
|
||||||
set "webDir=%runtimeDir%\supersonic-%module%\webapp"
|
|
||||||
set "CLASSPATH=%confDir%;%webDir%;%libDir%\*"
|
|
||||||
set "java-command=-Dfile.encoding=UTF-8 -Duser.language=Zh -Duser.region=CN -Duser.timezone=GMT+08 -Xms1024m -Xmx2048m -cp %CLASSPATH% %MAIN_CLASS%"
|
|
||||||
|
|
||||||
|
|
||||||
if "%command%"=="stop" (
|
|
||||||
call:STOP
|
|
||||||
goto :EOF
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%command%"=="restart" (
|
if "%command%"=="restart" (
|
||||||
call:STOP
|
call :STOP
|
||||||
)
|
call :START
|
||||||
|
|
||||||
::1. clear file
|
|
||||||
rd /s /q "%runtimeDir%"
|
|
||||||
mkdir "%runtimeDir%"
|
|
||||||
set "llm_path=%runtimeDir%\supersonic-standalone\llm"
|
|
||||||
|
|
||||||
if "%module%"=="llmparser" (
|
|
||||||
tar -zxvf "%buildDir%\supersonic.tar.gz" -C "%runtimeDir%"
|
|
||||||
for /d %%f in ("%runtimeDir%\launchers-standalone-*") do (
|
|
||||||
move "%%f" "%runtimeDir%\supersonic-standalone"
|
|
||||||
)
|
|
||||||
cd "%runtimeDir%"
|
|
||||||
"%pip_path%" install -r "%llm_path%\requirements.txt"
|
|
||||||
"%python_path%" -c "import langchain,fastapi,chromadb,tiktoken,uvicorn" >nul 2>&1
|
|
||||||
cd "%runtimeDir%\supersonic-standalone\llm\llm"
|
|
||||||
start "" /B uvicorn %start_name%:app --port %llm_port% --host %llm_host% > "%runtimeDir%\supersonic-standalone\llm\llm.log" 2>&1
|
|
||||||
echo "llm service started, see logs/error with logs/error command"
|
|
||||||
goto :EOF
|
goto :EOF
|
||||||
)
|
) else if "%command%"=="start" (
|
||||||
|
call :START
|
||||||
tar -zxvf "%buildDir%\supersonic.tar.gz" -C "%runtimeDir%"
|
|
||||||
for /d %%f in ("%runtimeDir%\launchers-%module%-*") do (
|
|
||||||
move "%%f" "%runtimeDir%\supersonic-%module%"
|
|
||||||
)
|
|
||||||
|
|
||||||
if not exist "%runtimeDir%\supersonic-%module%\logs" mkdir "%runtimeDir%\supersonic-%module%\logs"
|
|
||||||
|
|
||||||
tar -zxvf "%buildDir%\supersonic-webapp.tar.gz" -C "%buildDir%"
|
|
||||||
if not exist "%runtimeDir%\supersonic-%module%\webapp" mkdir "%runtimeDir%\supersonic-%module%\webapp"
|
|
||||||
xcopy /s /e /h /y "%buildDir%\supersonic-webapp\*" "%runtimeDir%\supersonic-%module%\webapp"
|
|
||||||
if not exist "%runtimeDir%\supersonic-%module%\conf\webapp" mkdir "%runtimeDir%\supersonic-%module%\conf\webapp"
|
|
||||||
xcopy /s /e /h /y "%runtimeDir%\supersonic-%module%\webapp\*" "%runtimeDir%\supersonic-%module%\conf\webapp"
|
|
||||||
rd /s /q "%buildDir%\supersonic-webapp"
|
|
||||||
|
|
||||||
::3. start service
|
|
||||||
::start standalone service
|
|
||||||
if "%command%"=="start" (
|
|
||||||
call:START
|
|
||||||
goto :EOF
|
goto :EOF
|
||||||
)
|
) else if "%command%"=="stop" (
|
||||||
|
call :STOP
|
||||||
if "%command%"=="restart" (
|
goto :EOF
|
||||||
call:START
|
) else if "%command%"=="reload" (
|
||||||
|
call :RELOAD_EXAMPLE
|
||||||
|
goto :EOF
|
||||||
|
) else (
|
||||||
|
echo "Use command {start|stop|restart} to run."
|
||||||
goto :EOF
|
goto :EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
:START
|
:START
|
||||||
if "%module%"=="standalone" (
|
if "%service%"=="%llmparser_service%" (
|
||||||
cd "%runtimeDir%"
|
call :START_PYTHON
|
||||||
"%pip_path%" install -r "%llm_path%\requirements.txt"
|
goto :EOF
|
||||||
"%python_path%" -c "import langchain,fastapi,chromadb,tiktoken,uvicorn" >nul 2>&1
|
)
|
||||||
cd "%runtimeDir%\supersonic-standalone\llm\llm"
|
call :START_PYTHON
|
||||||
start "" /B uvicorn %start_name%:app --port %llm_port% --host %llm_host% > "%runtimeDir%\supersonic-standalone\llm\llm.log" 2>&1
|
call :START_JAVA
|
||||||
echo "llm service started, see logs/error with logs/error command"
|
|
||||||
)
|
|
||||||
start "supersonic" /B java %java-command%>"%runtimeDir%\supersonic-%module%\logs\info-%module%.log" 2>&1
|
|
||||||
echo "%module% service started, see logs/error with logs/error command"
|
|
||||||
goto :EOF
|
goto :EOF
|
||||||
|
|
||||||
|
|
||||||
:STOP
|
:STOP
|
||||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "python"') do (
|
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "python"') do (
|
||||||
taskkill /PID %%i /F
|
taskkill /PID %%i /F
|
||||||
echo "llm Process (PID = %%i) is killed."
|
echo "python service (PID = %%i) is killed."
|
||||||
)
|
)
|
||||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "java"') do (
|
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "java"') do (
|
||||||
taskkill /PID %%i /F
|
taskkill /PID %%i /F
|
||||||
echo "%module% Process (PID = %%i) is killed."
|
echo "java service (PID = %%i) is killed."
|
||||||
)
|
)
|
||||||
goto :EOF
|
goto :EOF
|
||||||
|
|
||||||
|
|
||||||
|
:START_PYTHON
|
||||||
|
echo 'python service starting'
|
||||||
|
cd "%pythonRunDir%"
|
||||||
|
start /B %python_path% supersonic_llmparser.py > %pythonRunDir%\llmparser.log 2>&1
|
||||||
|
timeout /t 6 >nul
|
||||||
|
echo 'python service started, see logs in llmparser/llmparser.log'
|
||||||
|
goto :EOF
|
||||||
|
|
||||||
|
:START_JAVA
|
||||||
|
echo 'java service starting'
|
||||||
|
cd "%javaRunDir%"
|
||||||
|
if not exist "%runtimeDir%\supersonic-standalone\logs" mkdir "%runtimeDir%\supersonic-standalone\logs"
|
||||||
|
set "libDir=%runtimeDir%\supersonic-%service%\lib"
|
||||||
|
set "confDir=%runtimeDir%\supersonic-%service%\conf"
|
||||||
|
set "webDir=%runtimeDir%\supersonic-%service%\webapp"
|
||||||
|
set "classpath=%confDir%;%webDir%;%libDir%\*"
|
||||||
|
set "java-command=-Dfile.encoding=UTF-8 -Duser.language=Zh -Duser.region=CN -Duser.timezone=GMT+08 -Xms1024m -Xmx2048m -cp %CLASSPATH% %MAIN_CLASS%"
|
||||||
|
start /B java %java-command% >nul 2>&1
|
||||||
|
echo 'java service started, see logs in logs/'
|
||||||
|
goto :EOF
|
||||||
|
|
||||||
|
:RELOAD_EXAMPLE
|
||||||
|
cd "%runtimeDir%\supersonic-standalone\llmparser\sql"
|
||||||
|
start %python_path% examples_reload_run.py
|
||||||
|
goto :EOF
|
||||||
Reference in New Issue
Block a user