52f0879948e0ddbc84d9cee4952630ebca724f1f
chmalee
  Mon Sep 11 14:32:41 2017 -0700
Adding check for genome-euro proximity to gbib to let them use new genome-euro mysql server, refs #19276

diff --git src/browserbox/root/updateBrowser.sh src/browserbox/root/updateBrowser.sh
index df7c739..bf7b835 100755
--- src/browserbox/root/updateBrowser.sh
+++ src/browserbox/root/updateBrowser.sh
@@ -453,18 +453,33 @@
 #sudo myisamchk --force --silent --fast /data/mysql/hg19/*.MYI /data/mysql/hgcentral/*.MYI /data/mysql/hgFixed/*.MYI 2> /dev/null
 mysqlcheck --all-databases --auto-repair --quick --fast --silent
 
 #LATENCY=`ping genome.ucsc.edu -n -c1 -q | grep rtt | cut -d' ' -f4 | cut -d/ -f2 | cut -d. -f1`
 #if [ "$LATENCY" -gt "90" ]; then
 #echo making low-latency changes
 /usr/local/apache/cgi-bin/hgMirror postRsyncUpdates
 
 # the local-only hg.conf settings file has to exist as it is included from hg.conf
 # In case it got deleted due to some error, recreate it
 if [ ! -f /usr/local/apache/cgi-bin/hg.conf.local ] ; then
    echo Creating /usr/local/apache/cgi-bin/hg.conf.local
    echo allowHgMirror=true > /usr/local/apache/cgi-bin/hg.conf.local
 fi
 
+# Sept 2017: check if genome-euro mysql server is closer
+if [ ! -f /usr/local/apache/trash/registration.txt ]; then
+   echo comparing latency: genome.ucsc.edu Vs. genome-euro.ucsc.edu
+   euroSpeed=$( (time -p (for i in `seq 10`; do curl -sSI genome-euro.ucsc.edu > /dev/null; done )) 2>&1 | grep real | cut -d' ' -f2 )
+   ucscSpeed=$( (time -p (for i in `seq 10`; do curl -sSI genome.ucsc.edu /dev/null; done )) 2>&1 | grep real | cut -d' ' -f2 )
+   if [[ $(awk '{if ($1 <= $2) print 1;}' <<< "$euroSpeed $ucscSpeed") -eq 1 ]]; then
+      echo genome-euro seems to be closer
+      echo modifying gbib to pull data from genome-euro instead of genome
+      sed -i s/slow-db.host=genome-mysql.cse.ucsc.edu/slow-db.host=genome-euro-2.soe.ucsc.edu/ /usr/local/apache/cgi-bin/hg.conf
+   else
+      echo genome.ucsc.edu seems to be closer
+      echo not modifying /usr/local/apache/cgi-bin/hg.conf
+   fi
+fi
+
 touch /root/lastUpdateTime.flag
 echo - GBiB update done
 cat /etc/issue | tr -s '\n'