mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
(improvement) simplify build and start script (#81)
This commit is contained in:
@@ -1,15 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "sbinDir=%~dp0"
|
|
||||||
set "baseDir=%~dp0.."
|
|
||||||
set "runtimeDir=%baseDir%\runtime"
|
|
||||||
set "buildDir=%baseDir%\build"
|
|
||||||
|
|
||||||
cd "%baseDir%"
|
|
||||||
|
|
||||||
rem 1. move package to build
|
|
||||||
copy "%baseDir%\..\launchers\chat\target\*.tar.gz" "%buildDir%\supersonic-chat.tar.gz"
|
|
||||||
|
|
||||||
endlocal
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
|
||||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
|
||||||
runtimeDir=$baseDir/runtime
|
|
||||||
buildDir=$baseDir/build
|
|
||||||
|
|
||||||
cd $baseDir
|
|
||||||
|
|
||||||
#1. move package to build
|
|
||||||
cp $baseDir/../launchers/chat/target/*.tar.gz ${buildDir}/supersonic-chat.tar.gz
|
|
||||||
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "sbinDir=%~dp0"
|
|
||||||
set "baseDir=%~dp0.."
|
|
||||||
set "buildDir=%baseDir%\build"
|
|
||||||
|
|
||||||
cd /d "%baseDir%\bin"
|
|
||||||
call build-standalone.bat
|
|
||||||
|
|
||||||
cd "%buildDir%"
|
|
||||||
tar -zxvf supersonic-webapp.tar.gz
|
|
||||||
move supersonic-webapp webapp
|
|
||||||
move webapp ..\..\launchers\standalone\target\classes
|
|
||||||
|
|
||||||
endlocal
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
|
||||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
|
||||||
buildDir=$baseDir/build
|
|
||||||
|
|
||||||
cd $baseDir/bin
|
|
||||||
sh build-standalone.sh
|
|
||||||
|
|
||||||
cd $buildDir
|
|
||||||
tar xvf supersonic-webapp.tar.gz
|
|
||||||
mv supersonic-webapp webapp
|
|
||||||
mv webapp ../../launchers/standalone/target/classes
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "sbinDir=%~dp0"
|
|
||||||
set "baseDir=%~dp0.."
|
|
||||||
set "runtimeDir=%baseDir%\runtime"
|
|
||||||
set "buildDir=%baseDir%\build"
|
|
||||||
|
|
||||||
echo '%baseDir%'
|
|
||||||
echo '%buildDir%'
|
|
||||||
|
|
||||||
|
|
||||||
cd "%baseDir%"
|
|
||||||
|
|
||||||
rem 1. build semantic service
|
|
||||||
del /q "%buildDir%\*.tar.gz"
|
|
||||||
rd /s /q dist
|
|
||||||
|
|
||||||
call mvn -f "%baseDir%\..\pom.xml" clean package -DskipTests
|
|
||||||
|
|
||||||
rem 2. move package to build
|
|
||||||
echo "%baseDir%\..\launchers\semantic\target\*.tar.gz"
|
|
||||||
echo "%buildDir%\supersonic-semantic.tar.gz"
|
|
||||||
copy "%baseDir%\..\launchers\semantic\target\*.tar.gz" "%buildDir%\supersonic-semantic.tar.gz"
|
|
||||||
|
|
||||||
rem 3. build webapp
|
|
||||||
cd "%baseDir%\..\webapp"
|
|
||||||
start-fe-prod.bat
|
|
||||||
copy /y "supersonic-webapp.tar.gz" "%buildDir%\"
|
|
||||||
|
|
||||||
endlocal
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
|
||||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
|
||||||
runtimeDir=$baseDir/runtime
|
|
||||||
buildDir=$baseDir/build
|
|
||||||
|
|
||||||
cd $baseDir
|
|
||||||
|
|
||||||
#1. build semantic service
|
|
||||||
rm -fr ${buildDir}/*.tar.gz
|
|
||||||
rm -fr dist
|
|
||||||
|
|
||||||
mvn -f $baseDir/../ clean package -DskipTests
|
|
||||||
|
|
||||||
#2. move package to build
|
|
||||||
cp $baseDir/../launchers/semantic/target/*.tar.gz ${buildDir}/supersonic-semantic.tar.gz
|
|
||||||
|
|
||||||
#3. build webapp
|
|
||||||
chmod +x $baseDir/../webapp/start-fe-prod.sh
|
|
||||||
cd ../webapp
|
|
||||||
sh ./start-fe-prod.sh
|
|
||||||
cp -fr ./supersonic-webapp.tar.gz ${buildDir}/
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
|
||||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
|
||||||
runtimeDir=$baseDir/../runtime
|
|
||||||
buildDir=$baseDir/build
|
|
||||||
|
|
||||||
cd $baseDir
|
|
||||||
|
|
||||||
#2. package lib
|
|
||||||
|
|
||||||
tar -zxvf ${buildDir}/supersonic-chat.tar.gz -C ${runtimeDir}
|
|
||||||
|
|
||||||
mv ${runtimeDir}/launchers-chat-* ${runtimeDir}/supersonic-chat
|
|
||||||
|
|
||||||
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
|
||||||
|
|
||||||
mkdir -p ${runtimeDir}/supersonic-chat/webapp
|
|
||||||
|
|
||||||
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-chat/webapp
|
|
||||||
|
|
||||||
rm -fr ${buildDir}/supersonic-webapp
|
|
||||||
|
|
||||||
json=$(cat ${runtimeDir}/supersonic-chat/webapp/supersonic.config.json)
|
|
||||||
json=$(echo $json | jq '.env="chat"')
|
|
||||||
echo $json > ${runtimeDir}/supersonic-chat/webapp/supersonic.config.json
|
|
||||||
|
|
||||||
#3. start service
|
|
||||||
#3.1 start chat service
|
|
||||||
echo ${runtimeDir}
|
|
||||||
sh ${runtimeDir}/supersonic-chat/bin/service.sh restart
|
|
||||||
|
|
||||||
#3.2 start llm service
|
|
||||||
sh ${runtimeDir}/supersonic-chat/llm/bin/service.sh restart
|
|
||||||
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
|
||||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
|
||||||
runtimeDir=$baseDir/../runtime
|
|
||||||
buildDir=$baseDir/build
|
|
||||||
|
|
||||||
cd $baseDir
|
|
||||||
|
|
||||||
#1. clear file
|
|
||||||
mkdir -p ${runtimeDir}
|
|
||||||
rm -fr ${runtimeDir}/*
|
|
||||||
|
|
||||||
#2. package lib
|
|
||||||
|
|
||||||
tar -zxvf ${buildDir}/supersonic-semantic.tar.gz -C ${runtimeDir}
|
|
||||||
|
|
||||||
mv ${runtimeDir}/launchers-semantic-* ${runtimeDir}/supersonic-semantic
|
|
||||||
|
|
||||||
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
|
||||||
|
|
||||||
mkdir -p ${runtimeDir}/supersonic-semantic/webapp
|
|
||||||
|
|
||||||
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-semantic/webapp
|
|
||||||
|
|
||||||
rm -fr ${buildDir}/supersonic-webapp
|
|
||||||
|
|
||||||
|
|
||||||
json=$(cat ${runtimeDir}/supersonic-semantic/webapp/supersonic.config.json)
|
|
||||||
json=$(echo $json | jq '.env="semantic"')
|
|
||||||
echo $json > ${runtimeDir}/supersonic-semantic/webapp/supersonic.config.json
|
|
||||||
|
|
||||||
#3. start service
|
|
||||||
sh ${runtimeDir}/supersonic-semantic/bin/service.sh restart
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "sbinDir=%~dp0"
|
|
||||||
set "baseDir=%~dp0.."
|
|
||||||
set "runtimeDir=%baseDir%\..\runtime"
|
|
||||||
set "buildDir=%baseDir%\build"
|
|
||||||
|
|
||||||
cd /d %baseDir%
|
|
||||||
|
|
||||||
::1. clear file
|
|
||||||
rd /s /q "%runtimeDir%"
|
|
||||||
mkdir "%runtimeDir%"
|
|
||||||
|
|
||||||
|
|
||||||
::2. package lib
|
|
||||||
:: Assuming you have tar utility installed in Windows
|
|
||||||
tar -zxvf "%buildDir%\supersonic.tar.gz" -C "%runtimeDir%"
|
|
||||||
|
|
||||||
for /d %%f in ("%runtimeDir%\launchers-standalone-*") do (
|
|
||||||
move "%%f" "%runtimeDir%\supersonic-standalone"
|
|
||||||
)
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
|
|
||||||
::3. start service
|
|
||||||
::start standalone service
|
|
||||||
call "%runtimeDir%\supersonic-standalone\bin\service.bat" restart
|
|
||||||
call "%runtimeDir%\supersonic-standalone\llm\bin\service.bat" restart
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
|
||||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
|
||||||
runtimeDir=$baseDir/../runtime
|
|
||||||
buildDir=$baseDir/build
|
|
||||||
|
|
||||||
cd $baseDir
|
|
||||||
|
|
||||||
#1. clear file
|
|
||||||
mkdir -p ${runtimeDir}
|
|
||||||
rm -fr ${runtimeDir}/*
|
|
||||||
|
|
||||||
#2. package lib
|
|
||||||
|
|
||||||
tar -zxvf ${buildDir}/supersonic.tar.gz -C ${runtimeDir}
|
|
||||||
|
|
||||||
mv ${runtimeDir}/launchers-standalone-* ${runtimeDir}/supersonic-standalone
|
|
||||||
|
|
||||||
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
|
||||||
|
|
||||||
mkdir -p ${runtimeDir}/supersonic-standalone/webapp
|
|
||||||
|
|
||||||
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-standalone/webapp
|
|
||||||
|
|
||||||
rm -fr ${buildDir}/supersonic-webapp
|
|
||||||
|
|
||||||
#3. start service
|
|
||||||
#start standalone service
|
|
||||||
sh ${runtimeDir}/supersonic-standalone/bin/service.sh restart
|
|
||||||
#start llm service
|
|
||||||
sh ${runtimeDir}/supersonic-standalone/llm/bin/service.sh restart
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "sbinDir=%~dp0"
|
|
||||||
set "baseDir=%~dp0.."
|
|
||||||
set "runtimeDir=%baseDir%\..\runtime"
|
|
||||||
set "buildDir=%baseDir%\build"
|
|
||||||
|
|
||||||
::3. start service
|
|
||||||
::start standalone service
|
|
||||||
call "%runtimeDir%\supersonic-standalone\bin\service.bat" stop
|
|
||||||
call "%runtimeDir%\supersonic-standalone\llm\bin\service.bat" stop
|
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
set "sbinDir=%~dp0"
|
set "sbinDir=%~dp0"
|
||||||
set "baseDir=%~dp0.."
|
set "baseDir=%~dp0.."
|
||||||
set "runtimeDir=%baseDir%\runtime"
|
|
||||||
set "buildDir=%baseDir%\build"
|
set "buildDir=%baseDir%\build"
|
||||||
|
|
||||||
cd "%baseDir%"
|
|
||||||
|
|
||||||
rem 1. build semantic chat service
|
rem 1. build semantic chat service
|
||||||
del /q "%buildDir%\*.tar.gz" 2>NUL
|
del /q "%buildDir%\*.tar.gz" 2>NUL
|
||||||
@@ -15,11 +12,19 @@ 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"
|
||||||
|
echo f|xcopy "%baseDir%\..\launchers\semantic\target\*.tar.gz" "%buildDir%\supersonic-semantic.tar.gz"
|
||||||
|
echo f|xcopy "%baseDir%\..\launchers\chat\target\*.tar.gz" "%buildDir%\supersonic-chat.tar.gz"
|
||||||
|
|
||||||
rem 3. build webapp
|
rem 3. build 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%\"
|
||||||
|
|
||||||
endlocal
|
|
||||||
|
cd "%buildDir%"
|
||||||
|
tar -zxvf supersonic-webapp.tar.gz
|
||||||
|
move supersonic-webapp webapp
|
||||||
|
move webapp ..\..\launchers\standalone\target\classes
|
||||||
|
|
||||||
|
endlocal
|
||||||
9
assembly/bin/build-standalone.sh → assembly/bin/supersonic-build.sh
Executable file → Normal file
9
assembly/bin/build-standalone.sh → assembly/bin/supersonic-build.sh
Executable file → Normal file
@@ -15,9 +15,18 @@ mvn -f $baseDir/../ clean package -DskipTests
|
|||||||
|
|
||||||
#2. move package to build
|
#2. move package to build
|
||||||
cp $baseDir/../launchers/standalone/target/*.tar.gz ${buildDir}/supersonic.tar.gz
|
cp $baseDir/../launchers/standalone/target/*.tar.gz ${buildDir}/supersonic.tar.gz
|
||||||
|
cp $baseDir/../launchers/semantic/target/*.tar.gz ${buildDir}/supersonic-semantic.tar.gz
|
||||||
|
cp $baseDir/../launchers/chat/target/*.tar.gz ${buildDir}/supersonic-chat.tar.gz
|
||||||
|
|
||||||
|
|
||||||
#3. build webapp
|
#3. build webapp
|
||||||
chmod +x $baseDir/../webapp/start-fe-prod.sh
|
chmod +x $baseDir/../webapp/start-fe-prod.sh
|
||||||
cd ../webapp
|
cd ../webapp
|
||||||
sh ./start-fe-prod.sh
|
sh ./start-fe-prod.sh
|
||||||
cp -fr ./supersonic-webapp.tar.gz ${buildDir}/
|
cp -fr ./supersonic-webapp.tar.gz ${buildDir}/
|
||||||
|
|
||||||
|
|
||||||
|
cd $buildDir
|
||||||
|
tar xvf supersonic-webapp.tar.gz
|
||||||
|
mv supersonic-webapp webapp
|
||||||
|
mv webapp ../../launchers/standalone/target/classes
|
||||||
120
assembly/bin/supersonic-daemon.bat
Normal file
120
assembly/bin/supersonic-daemon.bat
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
set "sbinDir=%~dp0"
|
||||||
|
set "baseDir=%~dp0.."
|
||||||
|
set "runtimeDir=%baseDir%\..\runtime"
|
||||||
|
set "buildDir=%baseDir%\build"
|
||||||
|
|
||||||
|
set "command=%~1"
|
||||||
|
set "module=%~2"
|
||||||
|
|
||||||
|
set "APP_NAME=standalone-service"
|
||||||
|
set "MAIN_CLASS=com.tencent.supersonic.StandaloneLauncher"
|
||||||
|
|
||||||
|
set "python_path=python"
|
||||||
|
set "pip_path=pip3.9"
|
||||||
|
set "llm_host=127.0.0.1"
|
||||||
|
set "llm_port=9092"
|
||||||
|
set "start_name=api_service"
|
||||||
|
|
||||||
|
set "llm_path=%baseDir%\..\chat\core\src\main\python"
|
||||||
|
|
||||||
|
if "%module%"=="" (
|
||||||
|
set "module=standalone"
|
||||||
|
) 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%"=="" (
|
||||||
|
set "command=restart"
|
||||||
|
)
|
||||||
|
|
||||||
|
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" (
|
||||||
|
call:STOP
|
||||||
|
)
|
||||||
|
|
||||||
|
::1. clear file
|
||||||
|
rd /s /q "%runtimeDir%"
|
||||||
|
mkdir "%runtimeDir%"
|
||||||
|
|
||||||
|
if "%module%"=="llmparser" (
|
||||||
|
tar -zxvf "%buildDir%\supersonic-standalone.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
|
||||||
|
)
|
||||||
|
|
||||||
|
tar -zxvf "%buildDir%\supersonic-%module%.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
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%command%"=="restart" (
|
||||||
|
call:START
|
||||||
|
goto :EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
:START
|
||||||
|
if "%module%"=="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"
|
||||||
|
)
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
:STOP
|
||||||
|
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "python"') do (
|
||||||
|
taskkill /PID %%i /F
|
||||||
|
echo "llm Process (PID = %%i) is killed."
|
||||||
|
)
|
||||||
|
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "java"') do (
|
||||||
|
taskkill /PID %%i /F
|
||||||
|
echo "%module% Process (PID = %%i) is killed."
|
||||||
|
)
|
||||||
|
goto :EOF
|
||||||
112
assembly/bin/supersonic-daemon.sh
Normal file
112
assembly/bin/supersonic-daemon.sh
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
||||||
|
runtimeDir=$baseDir/../runtime
|
||||||
|
buildDir=$baseDir/build
|
||||||
|
|
||||||
|
command=$1
|
||||||
|
service=$2
|
||||||
|
|
||||||
|
cd $baseDir
|
||||||
|
if [[ "$service" == "semantic" || -z "$service" ]] && [ "$command" != "stop" ]; then
|
||||||
|
#1. clear file
|
||||||
|
mkdir -p ${runtimeDir}
|
||||||
|
rm -fr ${runtimeDir}/*
|
||||||
|
|
||||||
|
#2. package lib
|
||||||
|
|
||||||
|
tar -zxvf ${buildDir}/supersonic.tar.gz -C ${runtimeDir}
|
||||||
|
tar -zxvf ${buildDir}/supersonic-chat.tar.gz -C ${runtimeDir}
|
||||||
|
tar -zxvf ${buildDir}/supersonic-semantic.tar.gz -C ${runtimeDir}
|
||||||
|
|
||||||
|
mv ${runtimeDir}/launchers-standalone-* ${runtimeDir}/supersonic-standalone
|
||||||
|
mv ${runtimeDir}/launchers-chat-* ${runtimeDir}/supersonic-chat
|
||||||
|
mv ${runtimeDir}/launchers-semantic-* ${runtimeDir}/supersonic-semantic
|
||||||
|
|
||||||
|
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
||||||
|
|
||||||
|
mkdir -p ${runtimeDir}/supersonic-semantic/webapp
|
||||||
|
mkdir -p ${runtimeDir}/supersonic-chat/webapp
|
||||||
|
mkdir -p ${runtimeDir}/supersonic-standalone/webapp
|
||||||
|
|
||||||
|
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-semantic/webapp
|
||||||
|
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-chat/webapp
|
||||||
|
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-standalone/webapp
|
||||||
|
|
||||||
|
rm -fr ${buildDir}/supersonic-webapp
|
||||||
|
fi
|
||||||
|
if [[ "$service" == "semantic" ]]; then
|
||||||
|
json=$(cat ${runtimeDir}/supersonic-semantic/webapp/supersonic.config.json)
|
||||||
|
json=$(echo $json | jq '.env="semantic"')
|
||||||
|
echo $json > ${runtimeDir}/supersonic-semantic/webapp/supersonic.config.json
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$service" == "chat" ]]; then
|
||||||
|
json=$(cat ${runtimeDir}/supersonic-chat/webapp/supersonic.config.json)
|
||||||
|
json=$(echo $json | jq '.env="chat"')
|
||||||
|
echo $json > ${runtimeDir}/supersonic-chat/webapp/supersonic.config.json
|
||||||
|
fi
|
||||||
|
echo $command
|
||||||
|
echo $service
|
||||||
|
case "$command" in
|
||||||
|
start)
|
||||||
|
if [[ "$service" == "semantic" ]];then
|
||||||
|
echo -e "Starting semantic"
|
||||||
|
sh ${runtimeDir}/supersonic-semantic/bin/service.sh start
|
||||||
|
elif [[ "$service" == "chat" ]];then
|
||||||
|
echo -e "Starting chat"
|
||||||
|
sh ${runtimeDir}/supersonic-chat/bin/service.sh start
|
||||||
|
elif [[ "$service" == "llmparser" ]];then
|
||||||
|
echo -e "Starting LLM"
|
||||||
|
sh ${runtimeDir}/supersonic-chat/llm/bin/service.sh start
|
||||||
|
elif [[ -z "$service" ]]; then
|
||||||
|
echo -e "Starting supersonic"
|
||||||
|
sh ${runtimeDir}/supersonic-standalone/bin/service.sh start
|
||||||
|
sh ${runtimeDir}/supersonic-chat/llm/bin/service.sh start
|
||||||
|
else
|
||||||
|
echo "Use command {semantic|semantic||} to run."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
if [[ "$service" == "semantic" ]];then
|
||||||
|
echo -e "Stopping semantic"
|
||||||
|
sh ${runtimeDir}/supersonic-semantic/bin/service.sh stop
|
||||||
|
elif [[ "$service" == "chat" ]];then
|
||||||
|
echo -e "Stopping chat"
|
||||||
|
sh ${runtimeDir}/supersonic-chat/bin/service.sh stop
|
||||||
|
elif [[ "$service" == "llmparser" ]];then
|
||||||
|
echo -e "Stopping LLM"
|
||||||
|
sh ${runtimeDir}/supersonic-chat/llm/bin/service.sh stop
|
||||||
|
elif [[ -z "$service" ]]; then
|
||||||
|
echo -e "Stopping supersonic"
|
||||||
|
sh ${runtimeDir}/supersonic-standalone/bin/service.sh stop
|
||||||
|
sh ${runtimeDir}/supersonic-chat/llm/bin/service.sh stop
|
||||||
|
else
|
||||||
|
echo "Use command {semantic|semantic||} to run."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
if [[ "$service" == "semantic" ]];then
|
||||||
|
echo -e "Restarting semantic"
|
||||||
|
sh ${runtimeDir}/supersonic-semantic/bin/service.sh restart
|
||||||
|
elif [[ "$service" == "chat" ]];then
|
||||||
|
echo -e "Restarting chat"
|
||||||
|
sh ${runtimeDir}/supersonic-chat/bin/service.sh restart
|
||||||
|
elif [[ "$service" == "llmparser" ]];then
|
||||||
|
echo -e "Restarting LLM"
|
||||||
|
sh ${runtimeDir}/supersonic-chat/llm/bin/service.sh restart
|
||||||
|
elif [[ -z "$service" ]]; then
|
||||||
|
echo -e "Restarting supersonic"
|
||||||
|
sh ${runtimeDir}/supersonic-standalone/bin/service.sh restart
|
||||||
|
sh ${runtimeDir}/supersonic-chat/llm/bin/service.sh restart
|
||||||
|
else
|
||||||
|
echo "Use command {semantic|semantic||} to run."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Use command {start|stop|status|restart} to run."
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
@echo off
|
|
||||||
set "python_path=python"
|
|
||||||
set "pip_path=pip3.9"
|
|
||||||
set "llm_host=127.0.0.1"
|
|
||||||
set "llm_port=9092"
|
|
||||||
set "start_name=api_service"
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "binDir=%~dp0"
|
|
||||||
cd /d "%binDir%.."
|
|
||||||
set "baseDir=%cd%"
|
|
||||||
echo %binDir%
|
|
||||||
|
|
||||||
call "%binDir%\env.bat"
|
|
||||||
|
|
||||||
"%pip_path%" install -r "%baseDir%\requirements.txt"
|
|
||||||
|
|
||||||
"%python_path%" -c "import langchain,fastapi,chromadb,tiktoken,uvicorn" >nul 2>&1
|
|
||||||
if "%errorlevel%" equ 0 (
|
|
||||||
echo install ok, will pass
|
|
||||||
) else (
|
|
||||||
if "%errorlevel%" equ 1 (
|
|
||||||
echo install ok
|
|
||||||
) else (
|
|
||||||
echo install fail, but if it can be started normally, it will not affect
|
|
||||||
)
|
|
||||||
)
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "binDir=%~dp0"
|
|
||||||
cd /d "%binDir%.."
|
|
||||||
set "baseDir=%cd%"
|
|
||||||
|
|
||||||
call "%binDir%\env.bat"
|
|
||||||
echo "%binDir%"
|
|
||||||
|
|
||||||
if "%llm_host%"=="" (
|
|
||||||
echo llm_host llm_port is not set
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
if "%python_path%"=="" (
|
|
||||||
echo please set env value python_path, pip_path to python, pip path by export cmd
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
call "%binDir%\install.bat"
|
|
||||||
cd "%baseDir%\llm"
|
|
||||||
start "" /B uvicorn %start_name%:app --port %llm_port% --host %llm_host% > "%baseDir%\llm.log" 2>&1
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "binDir=%~dp0"
|
|
||||||
cd /d "%binDir%.."
|
|
||||||
set "baseDir=%cd%"
|
|
||||||
|
|
||||||
call "%baseDir%\bin\env.bat"
|
|
||||||
|
|
||||||
set "command=%~1"
|
|
||||||
|
|
||||||
|
|
||||||
if "%command%"=="start" (
|
|
||||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "Python"') do (
|
|
||||||
taskkill /PID %%i /F
|
|
||||||
echo "Process (PID = %%i) is running."
|
|
||||||
goto :EOF
|
|
||||||
)
|
|
||||||
"%baseDir%\bin\run.bat"
|
|
||||||
echo "llm service started, see logs/error with logs/error command"
|
|
||||||
goto :EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if "%command%"=="stop" (
|
|
||||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "Python"') do (
|
|
||||||
taskkill /PID %%i /F
|
|
||||||
echo "Process (PID = %%i) is killed."
|
|
||||||
goto :EOF
|
|
||||||
)
|
|
||||||
echo "Process is not running."
|
|
||||||
goto :EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if "%command%"=="restart" (
|
|
||||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "Python"') do (
|
|
||||||
taskkill /PID %%i /F
|
|
||||||
echo "Process (PID = %%i) is killed."
|
|
||||||
)
|
|
||||||
"%baseDir%\bin\run.bat"
|
|
||||||
echo "Process started, see logs/error with logs/error command"
|
|
||||||
goto :EOF
|
|
||||||
)
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
@echo off
|
|
||||||
set "APP_NAME=chat-service"
|
|
||||||
set "MAIN_CLASS=com.tencent.supersonic.StandaloneLauncher"
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "binDir=%~dp0"
|
|
||||||
set "baseDir=%~dp0.."
|
|
||||||
set "libDir=%baseDir%\lib"
|
|
||||||
set "confDir=%baseDir%\conf"
|
|
||||||
set "webDir=%baseDir%\webapp"
|
|
||||||
|
|
||||||
call "%baseDir%\bin\env.bat"
|
|
||||||
|
|
||||||
set "CLASSPATH=%confDir%;%webDir%;%libDir%\*"
|
|
||||||
|
|
||||||
set "LANG=zh_CN.UTF-8"
|
|
||||||
|
|
||||||
cd /d "%baseDir%"
|
|
||||||
|
|
||||||
set "command=-Dfile.encoding=UTF-8 -Duser.language=Zh -Duser.region=CN -Duser.timezone=GMT+08 -Xms1024m -Xmx2048m -cp %CLASSPATH% %MAIN_CLASS%"
|
|
||||||
|
|
||||||
if not exist "%baseDir%\logs" (
|
|
||||||
mkdir "%baseDir%\logs"
|
|
||||||
)
|
|
||||||
|
|
||||||
if "%is_test%"=="true" (
|
|
||||||
start "supersonic" /B java -Dspring.profiles.active=dev %command% >nul 2>"%baseDir%\logs\error.log"
|
|
||||||
) else (
|
|
||||||
start "supersonic" /B java %command% >nul 2>"%baseDir%\logs\error.log"
|
|
||||||
)
|
|
||||||
|
|
||||||
endlocal
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "binDir=%~dp0"
|
|
||||||
set "baseDir=%~dp0.."
|
|
||||||
set "confDir=%baseDir%\conf"
|
|
||||||
call "%baseDir%\bin\env.bat"
|
|
||||||
|
|
||||||
set "command=%~1"
|
|
||||||
|
|
||||||
|
|
||||||
if "%command%"=="start" (
|
|
||||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "java"') do (
|
|
||||||
echo "Process (PID = %%i) is running."
|
|
||||||
goto :EOF
|
|
||||||
)
|
|
||||||
echo "Starting %APP_NAME%"
|
|
||||||
"%baseDir%\bin\run.bat" %MAIN_CLASS%
|
|
||||||
echo "Process started, see logs/error with logs/error command"
|
|
||||||
goto :EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if "%command%"=="stop" (
|
|
||||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "java"') do (
|
|
||||||
taskkill /PID %%i /F
|
|
||||||
echo "Process (PID = %%i) is killed."
|
|
||||||
goto :EOF
|
|
||||||
)
|
|
||||||
echo "Process is not running."
|
|
||||||
goto :EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if "%command%"=="restart" (
|
|
||||||
for /f "tokens=2" %%i in ('tasklist ^| findstr /i "java"') do (
|
|
||||||
taskkill /PID %%i /F
|
|
||||||
echo "Process (PID = %%i) is killed."
|
|
||||||
)
|
|
||||||
"%baseDir%\bin\run.bat" %MAIN_CLASS%
|
|
||||||
echo "%APP_NAME% started, see logs/error with logs/error command"
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user