Files
Commonwealth-Online-Public/server/start.bat
T
andrewandCursor 9482fc3c5f Add port troubleshooting and fix script
- Add fix-port.bat to handle 'port already in use' errors
- Detect blocking process and kill it, or prompt to use different port
- Updated start.bat to detect startup failures and offer fix
- Updated README.md with troubleshooting guide for port conflicts

Users can now easily resolve port 7777 conflicts by running fix-port.bat
or using --port override on the CLI.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-09 20:46:45 +12:00

65 lines
1.6 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
echo.
echo ================================================================================
echo Commonwealth Online Server - Start Script
echo ================================================================================
echo.
REM Check if Python is installed
python --version >nul 2>&1
if errorlevel 1 (
echo ERROR: Python is not installed or not in PATH.
echo Please install Python 3.9+ from https://www.python.org
pause
exit /b 1
)
echo Installing dependencies...
pip install -q typer rich 2>nul
if errorlevel 1 (
echo WARNING: Failed to install dependencies quietly. Retrying with output...
pip install typer rich
if errorlevel 1 (
echo ERROR: Failed to install required packages.
pause
exit /b 1
)
)
echo Dependencies installed.
echo.
REM Check if config file exists
if not exist "commonwealth-server.json" (
echo Generating default configuration file...
python consumer_server_cli.py config init commonwealth-server.json
if errorlevel 1 (
echo ERROR: Failed to generate config file.
pause
exit /b 1
)
echo.
)
echo Starting Commonwealth Online Server...
echo Press Ctrl+C to stop the server.
echo.
python consumer_server_cli.py serve --config commonwealth-server.json
REM Check if the error was port in use
if errorlevel 1 (
echo.
echo Server failed to start. If you see "Only one usage of each socket address"
echo error, the port may already be in use.
echo.
choice /C YN /N /M "Would you like to fix the port issue? (Y/N): "
if !errorlevel!==1 (
echo.
call fix-port.bat
)
)
pause