Skip to content

Commit

Permalink
enable multi-sn config
Browse files Browse the repository at this point in the history
  • Loading branch information
jreadey committed Jul 24, 2023
1 parent ae1e926 commit 5439203
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion admin/docker/docker-compose.aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ services:
- LOG_LEVEL=${LOG_LEVEL}
- HSDS_ENDPOINT=${HSDS_ENDPOINT}
ports:
- ${SN_PORT}:${SN_PORT}
- ${SN_PORT}:5101
depends_on:
- head
volumes:
Expand Down
2 changes: 1 addition & 1 deletion admin/docker/docker-compose.azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ services:
- LOG_LEVEL=${LOG_LEVEL}
- HSDS_ENDPOINT=${HSDS_ENDPOINT}
ports:
- ${SN_PORT}:${SN_PORT}
- ${SN_PORT}:5101
depends_on:
- head
volumes:
Expand Down
2 changes: 1 addition & 1 deletion admin/docker/docker-compose.posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
- BUCKET_NAME=${BUCKET_NAME}
- HSDS_ENDPOINT=${HSDS_ENDPOINT}
ports:
- ${SN_PORT}:${SN_PORT}
- ${SN_PORT}:5101
depends_on:
- head
volumes:
Expand Down
12 changes: 11 additions & 1 deletion hsds/servicenode.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,17 @@ def main():
sn_port = getPortFromUrl(sn_url)
else:
# create TCP url based on port address
sn_port = int(config.get("sn_port"))
sn_port_config = config.get("sn_port")
if isinstance(sn_port_config, str) and sn_port_config.find("-") > 0:
# multi-port mapping. e.g.: 5101-5104:5101
# just use the first int of the target port range
mapping = sn_port_config.split(":")
target_ports = mapping[0].split("-")
sn_port = int(target_ports[0])
else:
# regular port config
sn_port = int(config.get("sn_port"))

sn_url = f"http://localhost:{sn_port}"

if isUnixDomainUrl(sn_url):
Expand Down
22 changes: 21 additions & 1 deletion runall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,30 @@ else
docker-compose -f ${COMPOSE_FILE} up -d --scale sn=${SN_CORES} --scale dn=${DN_CORES}
fi

# get a url to one of the SN containers
# if SN_PORT is just an integer (like 5101), return that
# if it's a port range like: 5101-5104:5101, return first port (5101 in this case)
ports=$(echo $SN_PORT | tr ":" "\n")

for port_range in $ports
do
break
done

port_numbers=$(echo $port_range | tr "-" "\n")
for port_number in $port_numbers
do
break
done


# wait for the server to be ready
LOCAL_ENDPOINT="http://localhost:${port_number}"
echo "sending status request to: ${LOCAL_ENDPOINT}"
for i in {1..120}
do
STATUS_CODE=`curl -s -o /dev/null -w "%{http_code}" http://localhost:${SN_PORT}/about`

STATUS_CODE=`curl -s -o /dev/null -w "%{http_code}" ${LOCAL_ENDPOINT}/about`
if [[ $STATUS_CODE == "200" ]]; then
echo "service ready!"
break
Expand Down

0 comments on commit 5439203

Please sign in to comment.