@@ -20,6 +20,16 @@ if [ ! -d "$LOGS_DIR" ]; then
2020 mkdir -p " $LOGS_DIR "
2121fi
2222
23+ # The virtual environment is now created and populated by the Dockerfile.
24+ # We just need to ensure SCRIPT_DIR points to /app if this script is not run from /app
25+ # Assuming SCRIPT_DIR will be /app based on WORKDIR and entrypoint execution context
26+
27+ # Activate the pre-built virtual environment
28+ echo " Activating the pre-built virtual environment at $SCRIPT_DIR /.venv..."
29+ source " $SCRIPT_DIR /.venv/bin/activate"
30+
31+ # Dependency installation is now handled by the Dockerfile.
32+
2333# Find all subdirectories in the servers directory
2434subdirs=$( find " $SERVERS_DIR " -mindepth 1 -maxdepth 1 -type d | sort)
2535
@@ -39,23 +49,11 @@ for subdir in $subdirs; do
3949 # Move into the subdirectory
4050 cd " $subdir " || continue
4151
42- echo " Setting up Python environment..."
43- # Create a Python virtual environment using uv
44- uv venv --python 3.12
45-
46- # Activate the virtual environment
47- source .venv/bin/activate
48-
49- echo " Installing requirements in $( pwd) ..."
50- # Install requirements from pyproject.toml
51- if [ -f " pyproject.toml" ]; then
52- uv pip install --requirement pyproject.toml >> " $log_file " 2>&1
53- else
54- echo " Warning: pyproject.toml not found in $subdir " | tee -a " $log_file "
55- fi
52+ # Python environment setup is now global, so no local venv creation/activation needed here
5653
5754 echo " Starting server on port $port (logs in $log_file )..."
5855 # Start the server in the background with the current port and redirect output to log file
56+ # uv run will use the globally activated venv
5957 uv run python server.py --port $port >> " $log_file " 2>&1 &
6058
6159 # Store the process ID for potential cleanup later
@@ -65,8 +63,7 @@ for subdir in $subdirs; do
6563 # Save PID to a file for easy management
6664 echo " $server_pid " > " $pid_file "
6765
68- # Deactivate the virtual environment
69- deactivate
66+ # No local deactivation needed
7067
7168 # Return to the original directory
7269 cd " $SCRIPT_DIR "
@@ -77,6 +74,11 @@ for subdir in $subdirs; do
7774 echo " -----------------------------------"
7875done
7976
77+ # Deactivate the global virtual environment
78+ echo " Deactivating the global virtual environment."
79+ deactivate
80+
8081echo " All servers have been started. Logs are available in the $LOGS_DIR directory."
82+ echo " The shared virtual environment at $SCRIPT_DIR /.venv was used."
8183echo " To stop all servers, use: kill \$ (cat $LOGS_DIR /*.pid)"
8284echo " To view logs in real-time for a specific server, use: tail -f $LOGS_DIR /server_name_port.log"
0 commit comments