Skip to content

Commit 63a2476

Browse files
loop 10 times for checking config files and setting password (#63)
1 parent bba64eb commit 63a2476

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

seekdb/start.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,32 @@ fi
3333
# Execute the main process
3434
/usr/libexec/oceanbase/scripts/seekdb_systemd_start
3535

36+
OBSERVER_CONFIG_FILE="/var/lib/oceanbase/etc/observer.config.bin"
37+
for i in {1..10}; do
38+
echo "Loop iteration #$i"
39+
if [ -f "$OBSERVER_CONFIG_FILE" ]; then
40+
echo "File '$OBSERVER_CONFIG_FILE' found on attempt #$i."
41+
break
42+
fi
43+
sleep 1
44+
done
45+
obshell agent start --seekdb --base-dir=/var/lib/oceanbase
46+
3647
INITIALIZED_FLAG="/var/lib/oceanbase/.initialized"
3748

3849
if [ ! -f "$INITIALIZED_FLAG" ]; then
3950
# change password using obshell
40-
curl -X PUT "http://127.0.0.1:2886/api/v1/observer/user/root/password" -d "{\"password\":\"$ROOT_PASSWORD\"}" --unix-socket "/var/lib/oceanbase/run/obshell.sock"
51+
for i in {1..10}; do
52+
curl -X PUT "http://127.0.0.1:2886/api/v1/observer/user/root/password" -d "{\"password\":\"$ROOT_PASSWORD\"}" --unix-socket "/var/lib/oceanbase/run/obshell.sock"
53+
EXIT_STATUS=$?
54+
if [ $EXIT_STATUS -eq 0 ]; then
55+
echo "Command succeeded on attempt #$i."
56+
break # Exit the loop if successful
57+
else
58+
echo "Command failed on attempt #$i (exit status: $EXIT_STATUS). Retrying in 1 seconds..."
59+
sleep 1
60+
fi
61+
done
4162

4263
# Execute initialization scripts if INIT_SCRIPTS_PATH is set
4364
if [ -n "$INIT_SCRIPTS_PATH" ]; then

0 commit comments

Comments
 (0)