From 1387997010bba423ce69b4d37e57fe4068b9b268 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Wed, 27 Mar 2019 13:49:19 -0400 Subject: [PATCH] * Prints an error message and quit in case Jupyter did not start after 2 minutes. --- turing/calculations/launch_jupyter | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/turing/calculations/launch_jupyter b/turing/calculations/launch_jupyter index b0a25b9..7390601 100755 --- a/turing/calculations/launch_jupyter +++ b/turing/calculations/launch_jupyter @@ -88,13 +88,24 @@ echo " * launching jupyter notebook server" (srun -n 1 -c 2 -J juypter "${SLURM_ARGS[@]}" jupyter-notebook --no-browser --port=$((8000 + $RANDOM % 1000)) --ip=0.0.0.0 2>&1 | tee $jupyter_output > /dev/null) & echo " * waiting for Jupyter server to be ready ..." -for ((i=0; i < 90; ++i)); do +for ((i=0; i < 120; ++i)); do tokens=$(awk -F: '/ http:/ {print $3}' $jupyter_output) if [ -n "$tokens" ]; then break fi sleep 1s done +if [ -z "$tokens" ]; then + echo "Error: Cannot find the Jupyter server URL!" + echo + echo "Dump of Jupyter process output:" + echo "-------------------------------" + cat $jupyter_output + echo + echo "Exiting due to error..." + exit 2 +fi + # Don't use echo to avoid divulging the token (!!) port=${tokens%/*} token=${tokens#*token=}