fixed migration for old instances
This commit is contained in:
parent
d37ecf6071
commit
a69aa0a975
10 changed files with 463 additions and 86 deletions
|
|
@ -71,13 +71,26 @@ goto wait_pg
|
|||
:pg_ready
|
||||
echo [ok] PostgreSQL is ready
|
||||
|
||||
rem --- Postgres role/database naming (telesrv -> owpengram), one-time, opt-in
|
||||
rem Only runs for installs that already accepted the Docker naming migration
|
||||
rem above; a "telesrv"-naming install already said no to this rename theme
|
||||
rem once and isn't asked again. See deploy\migrate-db-naming.ps1.
|
||||
if "%DOCKER_PREFIX%"=="owpengram" (
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File deploy\migrate-db-naming.ps1 -ContainerName "%DOCKER_PREFIX%-postgres"
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
echo [ERROR] postgres naming migration failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
rem --- Build ------------------------------------------------------------------
|
||||
echo.
|
||||
echo == [3/4] Building server binaries ==
|
||||
if /i "%NO_BUILD%"=="true" (
|
||||
echo [cfg] skipping build, --no-build set
|
||||
if not exist "bin\telesrv.exe" (
|
||||
if not exist "bin\telesrv-admin.exe" (
|
||||
if not exist "bin\owpengram-server.exe" (
|
||||
if not exist "bin\owpengram-admin-panel.exe" (
|
||||
echo [ERROR] no binaries found in bin\ - run without --no-build first
|
||||
pause
|
||||
exit /b 1
|
||||
|
|
@ -85,17 +98,17 @@ if /i "%NO_BUILD%"=="true" (
|
|||
)
|
||||
) else (
|
||||
if not exist bin mkdir bin
|
||||
echo [cfg] building telesrv...
|
||||
go build -o bin\telesrv.exe .\cmd\telesrv
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [ERROR] failed to build telesrv
|
||||
echo [cfg] building owpengram-server...
|
||||
go build -o bin\owpengram-server.exe .\cmd\telesrv
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
echo [ERROR] failed to build owpengram-server
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo [cfg] building telesrv-admin...
|
||||
go build -o bin\telesrv-admin.exe .\cmd\telesrv-admin
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo [ERROR] failed to build telesrv-admin
|
||||
echo [cfg] building owpengram-admin-panel...
|
||||
go build -o bin\owpengram-admin-panel.exe .\cmd\telesrv-admin
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
echo [ERROR] failed to build owpengram-admin-panel
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
|
@ -104,38 +117,38 @@ if /i "%NO_BUILD%"=="true" (
|
|||
|
||||
rem --- Start servers ----------------------------------------------------------
|
||||
echo.
|
||||
echo == [4/4] Starting telesrv + telesrv-admin ==
|
||||
echo == [4/4] Starting owpengram-server + owpengram-admin-panel ==
|
||||
|
||||
if not exist "%LOG_DIR%" mkdir "%LOG_DIR%"
|
||||
set "TELESRV_LOG=%LOG_DIR%\telesrv.log"
|
||||
set "ADMIN_LOG=%LOG_DIR%\telesrv-admin.log"
|
||||
set "SERVER_LOG=%LOG_DIR%\owpengram-server.log"
|
||||
set "ADMIN_LOG=%LOG_DIR%\owpengram-admin-panel.log"
|
||||
|
||||
rem "start /B cmd /c ..." creates no window, so the earlier WINDOWTITLE-based
|
||||
rem taskkill in stop_server below never matched anything and silently killed
|
||||
rem nothing. Launch via Start-Process -PassThru instead and track the real
|
||||
rem PID. Still routed through cmd.exe /c so ">>log 2>&1" can merge stdout and
|
||||
rem stderr into one file the way the bash script does (telesrv's own zap
|
||||
rem stderr into one file the way the bash script does (the server's own zap
|
||||
rem logger writes to stderr, so splitting the streams would leave the "main"
|
||||
rem log file nearly empty); "taskkill /T" below kills the whole cmd+exe tree,
|
||||
rem not just the cmd.exe wrapper, so this still actually stops the process.
|
||||
set "TELESRV_PID="
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "(Start-Process -FilePath 'cmd.exe' -ArgumentList '/c bin\telesrv.exe >> \"%TELESRV_LOG%\" 2>&1' -WindowStyle Hidden -PassThru).Id"`) do set "TELESRV_PID=%%i"
|
||||
if not defined TELESRV_PID (
|
||||
echo [ERROR] failed to start telesrv
|
||||
set "SERVER_PID="
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "(Start-Process -FilePath 'cmd.exe' -ArgumentList '/c bin\owpengram-server.exe >> \"%SERVER_LOG%\" 2>&1' -WindowStyle Hidden -PassThru).Id"`) do set "SERVER_PID=%%i"
|
||||
if not defined SERVER_PID (
|
||||
echo [ERROR] failed to start owpengram-server
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo [ok] telesrv started (PID %TELESRV_PID%), logs -^> %TELESRV_LOG%
|
||||
echo [ok] owpengram-server started, PID %SERVER_PID%, logs -^> %SERVER_LOG%
|
||||
|
||||
set "ADMIN_PID="
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "(Start-Process -FilePath 'cmd.exe' -ArgumentList '/c bin\telesrv-admin.exe >> \"%ADMIN_LOG%\" 2>&1' -WindowStyle Hidden -PassThru).Id"`) do set "ADMIN_PID=%%i"
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "(Start-Process -FilePath 'cmd.exe' -ArgumentList '/c bin\owpengram-admin-panel.exe >> \"%ADMIN_LOG%\" 2>&1' -WindowStyle Hidden -PassThru).Id"`) do set "ADMIN_PID=%%i"
|
||||
if not defined ADMIN_PID (
|
||||
echo [ERROR] failed to start telesrv-admin
|
||||
taskkill /PID %TELESRV_PID% /T /F >nul 2>&1
|
||||
echo [ERROR] failed to start owpengram-admin-panel
|
||||
taskkill /PID %SERVER_PID% /T /F >nul 2>&1
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo [ok] telesrv-admin started (PID %ADMIN_PID%), logs -^> %ADMIN_LOG%
|
||||
echo [ok] owpengram-admin-panel started, PID %ADMIN_PID%, logs -^> %ADMIN_LOG%
|
||||
|
||||
echo.
|
||||
echo ============================================
|
||||
|
|
@ -143,42 +156,42 @@ echo OwpenGram server is running
|
|||
echo ============================================
|
||||
echo.
|
||||
echo Logs:
|
||||
echo telesrv: type %TELESRV_LOG%
|
||||
echo telesrv-admin: type %ADMIN_LOG%
|
||||
echo owpengram-server: type %SERVER_LOG%
|
||||
echo owpengram-admin-panel: type %ADMIN_LOG%
|
||||
echo.
|
||||
echo ============================================
|
||||
|
||||
rem --- Interactive menu ------------------------------------------------------
|
||||
:menu
|
||||
tasklist /FI "PID eq %TELESRV_PID%" 2>nul | find "%TELESRV_PID%" >nul
|
||||
tasklist /FI "PID eq %SERVER_PID%" 2>nul | find "%SERVER_PID%" >nul
|
||||
if errorlevel 1 (
|
||||
echo [WARN] telesrv PID %TELESRV_PID% exited unexpectedly
|
||||
echo Check %TELESRV_LOG% for details
|
||||
echo [WARN] owpengram-server PID %SERVER_PID% exited unexpectedly
|
||||
echo Check %SERVER_LOG% for details
|
||||
taskkill /PID %ADMIN_PID% /T /F >nul 2>&1
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
tasklist /FI "PID eq %ADMIN_PID%" 2>nul | find "%ADMIN_PID%" >nul
|
||||
if errorlevel 1 (
|
||||
echo [WARN] telesrv-admin PID %ADMIN_PID% exited unexpectedly
|
||||
echo [WARN] owpengram-admin-panel PID %ADMIN_PID% exited unexpectedly
|
||||
echo Check %ADMIN_LOG% for details
|
||||
taskkill /PID %TELESRV_PID% /T /F >nul 2>&1
|
||||
taskkill /PID %SERVER_PID% /T /F >nul 2>&1
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo [1] View telesrv logs (last 50 lines)
|
||||
echo [2] View telesrv-admin logs (last 50 lines)
|
||||
echo [1] View owpengram-server logs (last 50 lines)
|
||||
echo [2] View owpengram-admin-panel logs (last 50 lines)
|
||||
echo [3] View both logs (last 50 lines)
|
||||
echo [4] Follow telesrv logs (live)
|
||||
echo [5] Follow telesrv-admin logs (live)
|
||||
echo [4] Follow owpengram-server logs (live)
|
||||
echo [5] Follow owpengram-admin-panel logs (live)
|
||||
echo [q] Stop server and exit
|
||||
echo.
|
||||
set /p "choice= Choice: "
|
||||
|
||||
if "!choice!"=="1" (
|
||||
powershell -NoProfile -Command "Get-Content '%TELESRV_LOG%' -Tail 50 -ErrorAction SilentlyContinue"
|
||||
powershell -NoProfile -Command "Get-Content '%SERVER_LOG%' -Tail 50 -ErrorAction SilentlyContinue"
|
||||
goto menu
|
||||
)
|
||||
if "!choice!"=="2" (
|
||||
|
|
@ -186,15 +199,15 @@ if "!choice!"=="2" (
|
|||
goto menu
|
||||
)
|
||||
if "!choice!"=="3" (
|
||||
echo --- telesrv ---
|
||||
powershell -NoProfile -Command "Get-Content '%TELESRV_LOG%' -Tail 50 -ErrorAction SilentlyContinue"
|
||||
echo --- telesrv-admin ---
|
||||
echo --- owpengram-server ---
|
||||
powershell -NoProfile -Command "Get-Content '%SERVER_LOG%' -Tail 50 -ErrorAction SilentlyContinue"
|
||||
echo --- owpengram-admin-panel ---
|
||||
powershell -NoProfile -Command "Get-Content '%ADMIN_LOG%' -Tail 50 -ErrorAction SilentlyContinue"
|
||||
goto menu
|
||||
)
|
||||
if "!choice!"=="4" (
|
||||
echo Press Ctrl+C to stop following
|
||||
powershell -NoProfile -Command "Get-Content '%TELESRV_LOG%' -Wait -Tail 10"
|
||||
powershell -NoProfile -Command "Get-Content '%SERVER_LOG%' -Wait -Tail 10"
|
||||
goto menu
|
||||
)
|
||||
if "!choice!"=="5" (
|
||||
|
|
@ -208,8 +221,8 @@ goto menu
|
|||
|
||||
:stop_server
|
||||
echo.
|
||||
echo [stop] stopping telesrv and telesrv-admin ...
|
||||
if defined TELESRV_PID taskkill /PID %TELESRV_PID% /T /F >nul 2>&1
|
||||
echo [stop] stopping owpengram-server and owpengram-admin-panel ...
|
||||
if defined SERVER_PID taskkill /PID %SERVER_PID% /T /F >nul 2>&1
|
||||
if defined ADMIN_PID taskkill /PID %ADMIN_PID% /T /F >nul 2>&1
|
||||
echo [ok] stopped.
|
||||
exit /b 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue