Skip to content
Snippets Groups Projects
Commit 381a0bb2 authored by David Hoese's avatar David Hoese
Browse files

Update scripts to find unused ports

parent 1caa8abc
No related branches found
No related tags found
No related merge requests found
......@@ -57,3 +57,4 @@ And use the password set up during installation.
server and 8787 for dask clients by default.
* Jupyter lab does not currently allow connecting to unix sockets (sockets
with a pathname). See https://github.com/jupyter/notebook/issues/2503.
......@@ -10,14 +10,22 @@
module purge
oops() {
echo "OOPS: $*"
exit 1
echo "OOPS: $*"
exit 1
}
#export HDF5_USE_FILE_LOCKING="FALSE"
#export PYTROLL_CHUNK_SIZE="2048"
CONDA_ENV=/home/davidh/miniconda3
source $CONDA_ENV/bin/activate pangeo
echo "ssh -N -L 8888:`hostname`:8888 -L 8787:`hostname`:8787 $USER@iris" | tee -a ${HOME}/.jupyter_lab_connect.txt
jupyter lab --no-browser --ip=`hostname` --port=8888
# Hack to find two useable ports
PORTS=$(python -c 'import socket; s1=socket.socket(); s2=socket.socket(); s1.bind(("", 0)); s2.bind(("", 0)); print(s1.getsockname()[1], s2.getsockname()[1]); s1.close(); s2.close()')
export JLAB_PORT=$(echo $PORTS | cut -d' ' -f1)
export DASK_PORT=$(echo $PORTS | cut -d' ' -f2)
# Write out a usable SSH command to connect to jupyter lab
echo "ssh -N -L 8888:`hostname`:${JLAB_PORT} -L 8787:`hostname`:${DASK_PORT} $USER@iris" | tee -a ${HOME}/.jupyter_lab_connect.txt
# Start jupyter lab
jupyter lab --no-browser --ip=`hostname` --port ${JLAB_PORT}
......@@ -10,7 +10,7 @@ CONNECT_FILE="${HOME}/.jupyter_lab_connect.txt"
rm -f $CONNECT_FILE
# Tell slurm to run jupyter lab and write ssh command to CONNECT_FILE
sbatch --quiet "${SCRIPT_HOME}/start_jupyter_lab.sbatch"
sbatch --quiet "${SCRIPT_HOME}/start_jupyter_lab.sbatch" > /dev/null 2>&1
# Wait for slurm to start the job on a compute node
while [ ! -f $CONNECT_FILE ]; do
......@@ -19,7 +19,7 @@ while [ ! -f $CONNECT_FILE ]; do
done
# Wait for jupyter lab to completely start
echo "Job started, waiting 5 seconds for jupyter lab to start..."
echo "Job started, waiting 5 seconds for jupyter lab to start..." >&2
sleep 5
# Now that we know it has started print out the SSH command the user should
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment