75 lines
1.2 KiB
Batchfile
75 lines
1.2 KiB
Batchfile
@echo off
|
|
|
|
|
|
set PROJECT_DIR=%~dp0
|
|
set VENV_DIR=%PROJECT_DIR%.venv
|
|
|
|
|
|
if exist "%VENV_DIR%\Scripts\activate.bat" (
|
|
|
|
call "%VENV_DIR%\Scripts\activate.bat"
|
|
) else (
|
|
|
|
python -m venv "%VENV_DIR%"
|
|
call "%VENV_DIR%\Scripts\activate.bat"
|
|
|
|
if errorlevel 1 (
|
|
echo error: fail to create env
|
|
pause
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
|
|
if "%VIRTUAL_ENV%" == "" (
|
|
echo error: fail to activate env
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo installing dependence...
|
|
|
|
pip install -r requirements.txt
|
|
if errorlevel 1 (
|
|
echo error: fail to install dependence
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
pip install waitress
|
|
if errorlevel 1 (
|
|
echo error: fail to install waitress
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
|
|
echo reading port from config...
|
|
for /f "usebackq tokens=*" %%P in (`python -c "from src.file_store_api import ConfigManager; config=ConfigManager().load_config(); print(config.get('app', {}).get('list_port', 25580))"`) do (
|
|
set PORT=%%P
|
|
)
|
|
|
|
|
|
if "%PORT%"=="" (
|
|
set PORT=25580
|
|
echo can't read port,use custom port:25580
|
|
) else (
|
|
echo success read port: %PORT%
|
|
)
|
|
|
|
|
|
echo starting rebot_server...
|
|
echo listening at: %PORT%
|
|
|
|
|
|
waitress-serve --host=0.0.0.0 --port=%PORT% app:app
|
|
|
|
|
|
if errorlevel 1 (
|
|
echo error,fail to start
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
pause
|