-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_server.bat
More file actions
81 lines (71 loc) · 2.03 KB
/
start_server.bat
File metadata and controls
81 lines (71 loc) · 2.03 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
@echo off
setlocal enabledelayedexpansion
echo ========================================
echo PyChat Server Launcher
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 from https://www.python.org/
pause
exit /b 1
)
echo [1/4] Checking Python installation...
python --version
REM Check if virtual environment exists
if not exist ".venv\" (
echo.
echo [2/4] Creating virtual environment...
python -m venv .venv
if errorlevel 1 (
echo [ERROR] Failed to create virtual environment!
pause
exit /b 1
)
echo [OK] Virtual environment created successfully.
) else (
echo.
echo [2/4] Virtual environment already exists.
)
REM Activate virtual environment
echo.
echo [3/4] Activating virtual environment...
call .venv\Scripts\activate.bat
if errorlevel 1 (
echo [ERROR] Failed to activate virtual environment!
pause
exit /b 1
)
REM Check and install required packages
echo.
echo [4/4] Installing/checking required packages...
REM Check if cryptography is installed
.venv\Scripts\python.exe -c "import cryptography" >nul 2>&1
if errorlevel 1 (
echo Installing cryptography...
.venv\Scripts\python.exe -m pip install --upgrade pip >nul 2>&1
.venv\Scripts\python.exe -m pip install cryptography
if errorlevel 1 (
echo [ERROR] Failed to install cryptography!
pause
exit /b 1
)
echo [OK] cryptography installed successfully.
) else (
echo [OK] All required packages are already installed.
)
echo.
echo ========================================
echo Starting Multi-Channel PyChat Server
echo ========================================
echo.
REM Start the multichannel server
.venv\Scripts\python.exe server_multichannel.py
REM If server exits, pause so user can see any error messages
if errorlevel 1 (
echo.
echo [ERROR] Server exited with error code: %errorlevel%
pause
)