diff --git a/admin/docker/docker-compose.aws.yml b/admin/docker/docker-compose.aws.yml index c355a9ba..d8737ec7 100644 --- a/admin/docker/docker-compose.aws.yml +++ b/admin/docker/docker-compose.aws.yml @@ -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: diff --git a/admin/docker/docker-compose.azure.yml b/admin/docker/docker-compose.azure.yml index 9034dd7a..acaeab93 100644 --- a/admin/docker/docker-compose.azure.yml +++ b/admin/docker/docker-compose.azure.yml @@ -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: diff --git a/admin/docker/docker-compose.posix.yml b/admin/docker/docker-compose.posix.yml index 1b2ea3e1..0b536384 100644 --- a/admin/docker/docker-compose.posix.yml +++ b/admin/docker/docker-compose.posix.yml @@ -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: diff --git a/hsds/servicenode.py b/hsds/servicenode.py index 312fd54c..a95e7f8a 100755 --- a/hsds/servicenode.py +++ b/hsds/servicenode.py @@ -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): diff --git a/runall.sh b/runall.sh index 0ee7c69b..ac730686 100755 --- a/runall.sh +++ b/runall.sh @@ -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