Commit 67b942b5 authored by Fabio Montefuscolo's avatar Fabio Montefuscolo
Browse files

trying to sync start up

parent 5f27478f
Pipeline #3138 passed with stage
in 3 minutes and 50 seconds
#!/bin/bash
MY_IP=$(hostname -i | awk '{ print $1 }')
first_time=0
if [ -z "${CLUSTER_NAME}" ];
then
echo 'Set environment variable CLUSTER_NAME' > /dev/stderr
......@@ -8,14 +10,14 @@ then
fi
source /entrypoint/info_server.sh &
source /entrypoint/bootstrap.sh;
if [ -z "$(ls -A $PXC_DATA)" ];
then
mkdir -m 755 -p "${PXC_DATA}"
chown -R mysql: "${PXC_DATA}"
bootstrap_database
first_time=1
fi
if [ -z "$CLUSTER_JOIN" ];
......@@ -41,7 +43,7 @@ current=""
leader=""
for ip in $CLUSTER_JOIN;
do
if ping -c2 -i5 -W1 $ip;
if ping -c2 -i5 -W1 $ip > /dev/null;
then
if [ "$ip" != "$MY_IP" ];
then
......@@ -53,7 +55,7 @@ do
fi
fi
score=$(curl -v http://$ip:8888/score)
score=$(curl -s http://$ip:8888/score)
if [ -z "$current" ] || [[ "$score" -gt "$current" ]];
then
current=$score
......@@ -70,6 +72,22 @@ echo "#
# Leader: $leader
#"
if [ "$leader" = "$MY_IP" ];
then
online=""
elif [ "$first_time" = "1" ];
then
tries = 30
while [ "$tries" -gt "0" ] && ! echo 1 > /dev/tcp/$leader/3306;
do
tries=$(( $tries - 1 ))
sleep 5
done
fi
if [ "$(basename $1)" = "mysqld" ];
then
tail -F "${MYSQL_LOG_FILE}" &
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment