-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed198a5
commit 16ff5f9
Showing
4 changed files
with
159 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#! /bin/bash | ||
|
||
#SBATCH --partition=devel | ||
#SBATCH --ntasks=1 | ||
#SBATCH --time=00:05:00 | ||
|
||
|
||
# Launch model server, send back server URL and wait so that SLURM does not cancel the allocation. | ||
|
||
function get_available_port { | ||
# Define the range of ports to select from | ||
MIN_PORT=1024 | ||
MAX_PORT=65535 | ||
|
||
# Generate a random port number | ||
port=$(shuf -i $MIN_PORT-$MAX_PORT -n 1) | ||
|
||
# Check if the port is in use | ||
while lsof -Pi :$port -sTCP:LISTEN -t >/dev/null; do | ||
# If the port is in use, generate a new random port number | ||
port=$(shuf -i $MIN_PORT-$MAX_PORT -n 1) | ||
done | ||
|
||
echo $port | ||
} | ||
|
||
port=$(get_available_port) | ||
export PORT=$port | ||
|
||
# Assume that server sets the port according to the environment variable 'PORT'. | ||
# Otherwise the job script will be stuck waiting for model server's response. | ||
./testmodel & # CHANGE ME! | ||
|
||
|
||
host=$(hostname -I | awk '{print $1}') | ||
|
||
echo "Waiting for model server to respond at $host:$port..." | ||
while ! curl -s "http://$host:$port/Info" > /dev/null; do | ||
sleep 1 | ||
done | ||
echo "Model server responded" | ||
|
||
# Write server URL to file identified by HQ job ID. | ||
load_balancer_dir="." | ||
mkdir -p $UMBRIDGE_LOADBALANCER_COMM_FILEDIR | ||
echo "http://$host:$port" > "$UMBRIDGE_LOADBALANCER_COMM_FILEDIR/url-$SLURM_JOB_ID.txt" | ||
|
||
sleep infinity # keep the job occupied |