1#------------------------------------------- 2# wait for pgpool comes up 3#------------------------------------------- 4function wait_for_pgpool_startup { 5 timeout=20 6 7 while [ $timeout -gt 0 ] 8 do 9 $PGBIN/psql -p $PGPOOL_PORT -c "show pool_nodes" test >/dev/null 2>&1 10 if [ $? = 0 ];then 11 break; 12 fi 13 timeout=`expr $timeout - 1` 14 sleep 1 15 done 16} 17 18#------------------------------------------- 19# wait for primary/master failover done 20#------------------------------------------- 21function wait_for_failover_done { 22 timeout=20 23 24 while [ $timeout -gt 0 ] 25 do 26 $PGBIN/psql -p $PGPOOL_PORT -c "show pool_nodes" test >/dev/null 2>&1 27 if [ $? = 0 ];then 28 $PGBIN/psql -p $PGPOOL_PORT -c "show pool_nodes" test |egrep -i "primary|master">/dev/null 2>&1 29 if [ $? = 0 ];then 30 break; 31 fi 32 fi 33 timeout=`expr $timeout - 1` 34 echo "timeout: $timeout" 35 sleep 1 36 done 37} 38 39#------------------------------------------- 40# clean remaining processes and sockets 41#------------------------------------------- 42function clean_all { 43 pgrep pgpool | xargs kill -9 > /dev/null 2>&1 44 pgrep postgres | xargs kill -9 > /dev/null 2>&1 45 rm -f $PGSOCKET_DIR/.s.PGSQL.* 46} 47