Skip to content

Commit f9b9013

Browse files
fix: update emulator configuration to bind gRPC port to all interfaces
Co-Authored-By: Rushil Srivastava <[email protected]>
1 parent 38a5924 commit f9b9013

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

start-emulator.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Start socat in the background to forward external connections
5+
socat TCP-LISTEN:8123,fork,reuseaddr,bind=0.0.0.0 TCP:127.0.0.1:8124 &
6+
SOCAT_PID=$!
7+
8+
# Start emulator on internal port with gRPC binding
9+
/emulator -port 8124 -grpc_port 8124 -grpc_host 0.0.0.0 &
10+
EMULATOR_PID=$!
11+
12+
# Function to cleanup processes
13+
cleanup() {
14+
kill $SOCAT_PID $EMULATOR_PID 2>/dev/null || true
15+
}
16+
17+
# Set up trap
18+
trap cleanup EXIT
19+
20+
# Wait for emulator to be ready
21+
for i in $(seq 1 30); do
22+
if curl -s http://127.0.0.1:8124/v1/projects/test-project/locations/us-central1/queues > /dev/null; then
23+
echo "Emulator is ready on internal port!"
24+
if curl -s http://localhost:8123/v1/projects/test-project/locations/us-central1/queues > /dev/null; then
25+
echo "Emulator is accessible on external port!"
26+
break
27+
fi
28+
fi
29+
echo "Waiting for emulator... attempt $i"
30+
sleep 1
31+
done
32+
33+
# Keep the script running
34+
wait $EMULATOR_PID

0 commit comments

Comments
 (0)