@@ -26,14 +26,13 @@ case "$(uname -s)" in
26
26
;;
27
27
esac
28
28
29
- etcd_data_dir=${1:- " $tmpdir /etcd/data" }
30
- pidfile=" $etcd_data_dir /etcd.pid"
31
- tcp_port=${2:- 2379}
29
+ readonly etcd_data_dir=" ${1:- " $tmpdir /etcd/data" } "
30
+ readonly pidfile=" $etcd_data_dir /etcd.pid"
31
+ readonly tcp_port=" ${2:- 2379} "
32
32
33
- ETCD_VER=v3.4.6
34
-
35
- GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
36
- DOWNLOAD_URL=${GITHUB_URL}
33
+ readonly ETCD_VER=' v3.5.7'
34
+ readonly GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
35
+ readonly DOWNLOAD_URL=${GITHUB_URL}
37
36
38
37
rm -rf " ${tmpdir} /etcd-${ETCD_VER} "
39
38
@@ -60,7 +59,7 @@ rm -rf "$etcd_data_dir"
60
59
mkdir -p " $etcd_data_dir "
61
60
62
61
# daemonize(1) is installed under this path on Debian
63
- PATH=$PATH :/usr/sbin
62
+ PATH=" $PATH :/usr/sbin"
64
63
65
64
daemonize -p " $pidfile " -l " ${etcd_data_dir} /daemonize_lock" -- " $tmpdir /etcd-${ETCD_VER} /etcd" \
66
65
--data-dir " $etcd_data_dir " --name peer-discovery-0 --initial-advertise-peer-urls http://127.0.0.1:2380 \
@@ -71,11 +70,18 @@ daemonize -p "$pidfile" -l "${etcd_data_dir}/daemonize_lock" -- "$tmpdir/etcd-${
71
70
--initial-cluster peer-discovery-0=http://127.0.0.1:2380 \
72
71
--initial-cluster-state new
73
72
74
-
75
- for seconds in {1..30}; do
76
- " $tmpdir /etcd-${ETCD_VER} /etcdctl" put rabbitmq-ct rabbitmq-ct --dial-timeout=1s && break
77
- sleep 1
73
+ i=0
74
+ while [ " $i " -lt 30 ]
75
+ do
76
+ " $tmpdir /etcd-${ETCD_VER} /etcdctl" --endpoints=" 127.0.0.1:${tcp_port} " put rabbitmq-ct rabbitmq-ct --dial-timeout=1s && break
77
+ sleep 1
78
+ i=" $(( i+ 1 )) "
78
79
done
79
80
80
- echo ETCD_PID=$( cat " $pidfile " )
81
-
81
+ if [ " $i " -ge 30 ]
82
+ then
83
+ echo ' [ERROR] etcd did not start successfully!' 1>&2
84
+ exit 1
85
+ else
86
+ echo ETCD_PID=" $( cat " $pidfile " ) "
87
+ fi
0 commit comments