Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:14

0001 #!/bin/bash
0002 
0003 port=8080
0004 
0005 #look for open port
0006 while [ $port -lt 8090 ]; do
0007 #d=`netstat -tulpn 2>/dev/null | grep LISTEN | grep 127.0.0.1:$port |wc -l`
0008 d=`grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($2,i,2))}{print x":"strtonum("0x"substr($2,index($2,":")+1,4))}' | grep 127.0.0.1:$port |wc -l`
0009 if [ $d -eq "0" ]
0010 then
0011   break
0012 fi
0013 let port=port+1
0014 done
0015 
0016 if [ $port -ge 8090 ]
0017 then
0018   echo "could not find a port to use. Stopping test"
0019   exit 1
0020 fi
0021 
0022 echo "Testing jupyter using port $port"
0023 exit 0
0024 
0025 #open a notebook server, run for 20s and stop
0026 timeout 20s jupyter notebook --no-browser --port=$port
0027 
0028 #timeout has an exit code of 124 if a timeout has occured
0029 if [ $? -eq 124 ]
0030 then
0031    echo "Success (notebook stopped after 15s)"
0032    exit 0
0033 else
0034    echo "There was an error starting the notebook"
0035    exit $?
0036 fi
0037 
0038