-
Notifications
You must be signed in to change notification settings - Fork 314
Expand file tree
/
Copy pathstart.bat
More file actions
100 lines (91 loc) · 2.8 KB
/
Copy pathstart.bat
File metadata and controls
100 lines (91 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
@echo off
REM ============================================
REM TranslateBookWithLLM - Start Application
REM Quick Launch Script (with auto-update + restart loop)
REM ============================================
setlocal enabledelayedexpansion
chcp 65001 >nul 2>&1
cls
REM ========================================
REM BANNER
REM ========================================
echo.
echo TranslateBook with LLMs
echo --------------------------
echo.
REM ========================================
REM Check if setup was run
REM ========================================
if not exist "venv" (
echo [X] Virtual environment not found!
echo Please run setup-and-update.bat first to install.
echo.
pause
exit /b 1
)
REM ========================================
REM Activate Virtual Environment
REM ========================================
echo Initializing environment...
call venv\Scripts\activate.bat
if errorlevel 1 (
echo [X] Failed to activate virtual environment
echo Try running setup-and-update.bat to fix the installation
pause
exit /b 1
)
echo [OK] Environment ready
REM ========================================
REM Optional: pull latest code on startup
REM (mirrors start.sh behavior; safe no-op if git absent or no changes)
REM ========================================
git --version >nul 2>&1
if not errorlevel 1 (
echo Checking for code updates from Git...
git fetch >nul 2>&1
for /f %%i in ('git rev-parse HEAD 2^>nul') do set LOCAL_COMMIT=%%i
for /f %%i in ('git rev-parse @{u} 2^>nul') do set REMOTE_COMMIT=%%i
if not "!LOCAL_COMMIT!"=="!REMOTE_COMMIT!" (
if not "!REMOTE_COMMIT!"=="" (
echo Updates available, pulling latest changes...
git pull --ff-only
)
) else (
echo [OK] Code is up to date
)
) else (
echo [INFO] Git not available, skipping code update check
)
echo.
REM ========================================
REM LAUNCH APPLICATION (restart loop)
REM ----------------------------------------
REM The Python process can request a restart by exiting with code 42 (used by
REM the in-app auto-update flow). Any other exit code stops the loop.
REM ========================================
:run_server
echo Launching server...
echo.
echo Web interface: http://localhost:5000
echo Press Ctrl+C to stop the server
echo.
python translation_api.py
set EXITCODE=!ERRORLEVEL!
if "!EXITCODE!"=="42" (
echo.
echo --------------------------
echo Restart requested by in-app updater.
echo Re-installing dependencies if requirements.txt changed...
if exist "requirements.txt" (
pip install -r requirements.txt --upgrade --quiet
)
echo Relaunching...
echo.
goto run_server
)
REM If server stops normally
echo.
echo --------------------------
echo Server stopped (exit code !EXITCODE!).
echo.
pause