Skip to content

Commit 3e5c991

Browse files
committed
pass FE_MASTER_PORT set fe_mysql_port execute sql
1 parent 9f2481c commit 3e5c991

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

rootfs/docker-entrypoint.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,15 @@ _main() {
5757
if grep -q -i "stand" <<< "${RUN_MODE}"; then
5858
touch /etc/s6-overlay/s6-rc.d/user/contents.d/be
5959
touch /etc/s6-overlay/s6-rc.d/user/contents.d/fe
60-
fi
61-
62-
if grep -q -i "fe" <<< "${RUN_MODE}"; then
60+
touch /etc/s6-overlay/s6-rc.d/user/contents.d/cluster
61+
elif grep -q -i "fe" <<< "${RUN_MODE}"; then
6362
touch /etc/s6-overlay/s6-rc.d/user/contents.d/fe
64-
fi
65-
66-
if grep -q -i "be" <<< "${RUN_MODE}"; then
63+
touch /etc/s6-overlay/s6-rc.d/user/contents.d/cluster
64+
elif grep -q -i "be" <<< "${RUN_MODE}"; then
6765
touch /etc/s6-overlay/s6-rc.d/user/contents.d/be
66+
touch /etc/s6-overlay/s6-rc.d/user/contents.d/cluster
6867
fi
69-
touch /etc/s6-overlay/s6-rc.d/user/contents.d/cluster
68+
7069

7170

7271
exec /init

rootfs/etc/s6-overlay/s6-rc.d/cluster/run

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
set -eo pipefail
88

9+
10+
fe_mysql_port="9030"
11+
if [ -n "${FE_MASTER_PORT}" ]; then
12+
fe_mysql_port="${FE_MASTER_PORT}"
13+
fi
14+
915
if grep -q -i "stand" <<< "${RUN_MODE}"; then
1016

1117

@@ -17,11 +23,11 @@ if grep -q -i "stand" <<< "${RUN_MODE}"; then
1723
fi
1824

1925

20-
wait4x --timeout 86400s mysql "root@tcp(127.0.0.1:9030)/" && \
26+
wait4x --timeout 86400s mysql "root@tcp(127.0.0.1:${fe_mysql_port})/" && \
2127
(
2228
## check if the backend is already added
23-
if ! mysql -uroot -P9030 -h127.0.0.1 -e "show backends" | grep -q -E "${join_backend}.*9050"; then
24-
mysql -uroot -P9030 -h127.0.0.1 -e "ALTER SYSTEM ADD BACKEND '${join_backend}:9050'"
29+
if ! mysql -uroot -P${fe_mysql_port} -h127.0.0.1 -e "show backends" | grep -q -E "${join_backend}.*9050"; then
30+
mysql -uroot -P${fe_mysql_port} -h127.0.0.1 -e "ALTER SYSTEM ADD BACKEND '${join_backend}:9050'"
2531
fi
2632
)
2733
fi
@@ -30,7 +36,7 @@ fi
3036
## //TODO
3137
## will ignore BE_SERVERS
3238
## will ignore FQDN
33-
## will ignore FE_MASTER_PORT //TODO
39+
3440

3541

3642
if grep -q -i "fe" <<< "${RUN_MODE}"; then
@@ -50,6 +56,7 @@ if [ -n "${FE_SERVERS}" ]; then
5056

5157
# specific for k8s sts pod, because the FE_ID cant set var ENV
5258
# so we need to get the index from hostname
59+
# TODO need make sure it is indeed in k8s environment
5360
if [ -z "${FE_ID}" ]; then
5461
HOSTNAME="$(hostname -s)"
5562
if [[ $HOSTNAME =~ (.*)-([0-9]+)$ ]]; then
@@ -82,7 +89,7 @@ if [ -n "${FE_SERVERS}" ]; then
8289
done
8390
fi
8491

85-
wait4x --timeout 86400s mysql "root@tcp(${fe_master}:9030)/" && \
92+
wait4x --timeout 86400s mysql "root@tcp(${fe_master}:${fe_mysql_port})/" && \
8693
(
8794
for k in "${!fe_join[@]}"; do
8895
val="${fe_join[$k]}";
@@ -92,15 +99,13 @@ wait4x --timeout 86400s mysql "root@tcp(${fe_master}:9030)/" && \
9299
# echo "${val_grep}"
93100
# echo "###########################################"
94101
## check if the frontend is already added
95-
if ! mysql -uroot -P9030 -h${fe_master} -e "show frontends;" | grep -q -E "${val_grep}"; then
96-
mysql -uroot -P9030 -h${fe_master} -e "ALTER SYSTEM ADD FOLLOWER '${val}'"
102+
if ! mysql -uroot -P${fe_mysql_port} -h${fe_master} -e "show frontends;" | grep -q -E "${val_grep}"; then
103+
mysql -uroot -P${fe_mysql_port} -h${fe_master} -e "ALTER SYSTEM ADD FOLLOWER '${val}'"
97104
fi
98105
done
99106
)
100107

101-
# mysql -uroot -P9030 -hfe-01 -e "ALTER SYSTEM ADD FOLLOWER 'fe-02:9010'"
102-
# mysql -uroot -P9030 -hfe-01 -e "ALTER SYSTEM ADD FOLLOWER 'fe-03:9010'"
103-
# mysql -uroot -P9030 -hfe-01 -e "ALTER SYSTEM DROP FOLLOWER 'fe-04:9010'"
108+
104109

105110

106111
fi
@@ -132,7 +137,7 @@ if [ -n "${FE_SERVERS}" ]; then
132137
done
133138
fi
134139

135-
wait4x --timeout 86400s mysql "root@tcp(${fe_master}:9030)/" && \
140+
wait4x --timeout 86400s mysql "root@tcp(${fe_master}:${fe_mysql_port})/" && \
136141
(
137142
val="";
138143

@@ -143,8 +148,8 @@ wait4x --timeout 86400s mysql "root@tcp(${fe_master}:9030)/" && \
143148
fi
144149

145150
val_grep=${val//:/.*}
146-
if ! mysql -uroot -P9030 -h${fe_master} -e "show backends;" | grep -q -E "${val_grep}"; then
147-
mysql -uroot -P9030 -h${fe_master} -e "ALTER SYSTEM ADD BACKEND '${val}'"
151+
if ! mysql -uroot -P${fe_mysql_port} -h${fe_master} -e "show backends;" | grep -q -E "${val_grep}"; then
152+
mysql -uroot -P${fe_mysql_port} -h${fe_master} -e "ALTER SYSTEM ADD BACKEND '${val}'"
148153
fi
149154
)
150155

0 commit comments

Comments
 (0)