Complete C# server cutover

This commit is contained in:
Nomads_Reach
2026-08-16 02:36:32 -04:00
parent ddadf87423
commit 757e614cdd
79 changed files with 923 additions and 13129 deletions
+24 -84
View File
@@ -1,110 +1,50 @@
@echo off
setlocal enabledelayedexpansion
setlocal EnableExtensions EnableDelayedExpansion
cd /d "%~dp0"
echo.
echo ================================================================================
echo Commonwealth Online - Port 7777 in Use
echo ================================================================================
echo.
echo Port 7777 is currently in use by another process.
echo.
echo Options:
echo 1. Kill the process using port 7777 and restart server
echo 2. Use a different port (you will be prompted to enter one)
echo 3. Cancel and exit
echo.
echo 1. Kill the process using TCP 7777 and restart
echo 2. Start the server on a different port
echo 3. Cancel
choice /C 123 /N /M "Select option (1-3): "
set choice=%errorlevel%
if %choice%==1 goto kill_process
if %choice%==3 exit /b 0
if %choice%==2 goto change_port
if %choice%==3 goto exit_script
:kill_process
echo.
echo Finding process using port 7777...
for /f "tokens=5" %%a in ('netstat -aon ^| find ":7777"') do (
set PID=%%a
)
if defined PID (
echo Killing process with PID !PID!...
taskkill /PID !PID! /F >nul 2>&1
if errorlevel 1 (
echo ERROR: Could not kill process. Try running this script as Administrator.
pause
exit /b 1
)
echo Process killed successfully.
echo.
echo Waiting for port to be released...
timeout /t 2 /nobreak
echo.
echo Restarting server...
call start.bat
) else (
echo Could not determine which process is using port 7777.
echo Try:
echo - Restarting your computer
echo - Running as Administrator
echo - Or choose option 2 to use a different port
pause
set "PID="
for /f "tokens=5" %%A in ('netstat -aon ^| findstr /R /C:":7777 .*LISTENING"') do if not defined PID set "PID=%%A"
if not defined PID (
echo ERROR: Could not determine which process is using TCP 7777.
exit /b 1
)
goto end
echo Killing PID !PID!...
taskkill /PID !PID! /F >nul 2>&1 || (
echo ERROR: Could not kill PID !PID!. Try running as Administrator.
exit /b 1
)
timeout /t 2 /nobreak >nul
call start.bat
exit /b %ERRORLEVEL%
:change_port
echo.
set /p NEW_PORT="Enter desired port (1024-65535, default is 7777): "
if "!NEW_PORT!"=="" (
set NEW_PORT=7777
)
REM Validate port is a number between 1024 and 65535
set /p NEW_PORT="Enter desired port (1024-65535): "
for /f "delims=0123456789" %%A in ("!NEW_PORT!") do (
echo ERROR: Port must be a number.
pause
echo ERROR: Port must be numeric.
exit /b 1
)
if "!NEW_PORT!"=="" exit /b 1
if !NEW_PORT! lss 1024 (
echo ERROR: Port must be 1024 or higher.
pause
exit /b 1
)
if !NEW_PORT! gtr 65535 (
echo ERROR: Port must be 65535 or lower.
pause
exit /b 1
)
echo.
echo Updating commonwealth-server.json to use port !NEW_PORT!...
REM Create new config with updated port
(
echo {
echo "host": "0.0.0.0",
echo "port": !NEW_PORT!,
echo "server_name": "Commonwealth Online Server",
echo "max_players": 16,
echo "log_verbosity": "info"
echo }
) > commonwealth-server.json
echo Config updated. Starting server on port !NEW_PORT!...
echo.
python consumer_server_cli.py serve --config commonwealth-server.json
goto end
:exit_script
echo.
echo Cancelled.
exit /b 0
:end
pause
echo Starting on TCP/UDP !NEW_PORT!. This override does not rewrite commonwealth-server.json.
call start.bat --port !NEW_PORT!
exit /b %ERRORLEVEL%