Skip to content

Commit

Permalink
Handle cases when we have multiple IPs. (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
xusine authored Sep 24, 2022
1 parent ecd3291 commit 9ce2439
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions benchmarks/data-serving/server/files/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/bash
set -e

echo Server IP
hostname --ip-address
# It's possible that one machine has multiple ip addresses mapped to the hostname
# For instance, ARM image inside QEMU has this problem.
# Therefore, we will only keep the first IP address where the Cassandra server is also listened.

LISTEN_IP=$(cut --delimiter=" " -f1 <<< $(hostname --ip-address))

echo Server will listen on IP: $LISTEN_IP

if [ -z "$CASSANDRA_SEEDS" ]; then
NEED_INIT=1
Expand All @@ -22,13 +27,13 @@ if [ "$1" = 'cassandra' ] || [ "$1" = 'bash' ]; then

: ${CASSANDRA_LISTEN_ADDRESS='auto'}
if [ "$CASSANDRA_LISTEN_ADDRESS" = 'auto' ]; then
CASSANDRA_LISTEN_ADDRESS="$(hostname --ip-address)"
CASSANDRA_LISTEN_ADDRESS="$LISTEN_IP"
fi

: ${CASSANDRA_BROADCAST_ADDRESS="$CASSANDRA_LISTEN_ADDRESS"}

if [ "$CASSANDRA_BROADCAST_ADDRESS" = 'auto' ]; then
CASSANDRA_BROADCAST_ADDRESS="$(hostname --ip-address)"
CASSANDRA_BROADCAST_ADDRESS="$LISTEN_IP"
fi
: ${CASSANDRA_BROADCAST_RPC_ADDRESS:=$CASSANDRA_BROADCAST_ADDRESS}

Expand Down

0 comments on commit 9ce2439

Please sign in to comment.