22
33set -e
44
5- # Check if OPENAI_API_KEY is set
65if [ -z " $OPENAI_API_KEY " ]; then
76 echo " Error: OPENAI_API_KEY environment variable is not set"
87 echo " Please export OPENAI_API_KEY=<your-api-key>"
@@ -50,7 +49,7 @@ while [[ $# -gt 0 ]]; do
5049 echo " -s, --simulation-name NAME Simulation name (default: summer_vacation)"
5150 echo " -d, --daemon Keep server alive after simulation (default: false)"
5251 echo " -t, --tag TAG Docker image tag (default: latest)"
53- echo " -p, --host-port PORT Host port to bind (default: auto-detect from PORT env or 3000 )"
52+ echo " -p, --host-port PORT Host port to bind (default: auto-detect from server.json )"
5453 echo " --redis-host HOST Redis host (default: host.docker.internal)"
5554 echo " --redis-port PORT Redis port (default: 6379)"
5655 echo " -h, --help Show this help message"
@@ -63,10 +62,13 @@ while [[ $# -gt 0 ]]; do
6362 esac
6463done
6564
66- # Use PORT from environment or default to 3000
67- SERVER_PORT=" ${PORT:- 3000} "
65+ SERVER_CONFIG=" examples/server/server.json"
66+ SERVER_PORT=$( grep -o ' "port":[[:space:]]*[0-9]*' " $SERVER_CONFIG " | grep -o ' [0-9]*$' )
67+ if [ -z " $SERVER_PORT " ]; then
68+ echo " Warning: Could not determine port from server config, using default 9000"
69+ SERVER_PORT=9000
70+ fi
6871
69- # Function to find a free port
7072find_free_port () {
7173 local start_port=$1
7274 local port=$start_port
@@ -112,14 +114,12 @@ else
112114 echo " Host port: Docker will assign a random available port"
113115fi
114116
115- # Prepare port arguments
116117if [ -n " $HOST_PORT " ]; then
117118 PORT_ARGS=(-p " $HOST_PORT :$SERVER_PORT " )
118119else
119120 PORT_ARGS=(-P)
120121fi
121122
122- # Run container
123123docker run \
124124 --rm \
125125 -it \
0 commit comments