[Tool] add healthcheck in allin1-ubuntu (#62998)

* get the container health status by
```
docker inspect --format='{{.State.Health.Status}}' NAME|ID
```

Signed-off-by: Kevin Cai <kevin.cai@celerdata.com>
This commit is contained in:
Kevin Cai 2025-09-15 10:51:11 +08:00 committed by GitHub
parent 908b55543d
commit 742ea6ed37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 48 additions and 0 deletions

View File

@ -57,4 +57,5 @@ RUN cat be.conf >> $DEPLOYDIR/starrocks/be/conf/be.conf && \
rm -f be.conf fe.conf && \
mkdir -p $DEPLOYDIR/starrocks/fe/meta $DEPLOYDIR/starrocks/be/storage && touch /.dockerenv
HEALTHCHECK --interval=30s --timeout=15s --start-period=30s ./health_check.sh
CMD ./entrypoint.sh

View File

@ -0,0 +1,41 @@
#!/bin/bash
# Copyright 2021-present StarRocks, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
BOOTSTRAP_DONE_FILE=$SR_HOME/bootstrap_done
FE_DEFAULT_HTTP_PORT=8030
BE_DEFAULT_HTTP_PORT=8040
get_fe_http_port()
{
export_env_from_conf $SR_HOME/fe/conf/fe.conf
echo ${http_port:-$FE_DEFAULT_HTTP_PORT}
}
get_be_http_port()
{
export_env_from_conf $SR_HOME/be/conf/be.conf
echo ${be_http_port:-$BE_DEFAULT_HTTP_PORT}
}
test -f $BOOTSTRAP_DONE_FILE || exit 1
source $SR_HOME/fe/bin/common.sh
fe_http_port=`get_fe_http_port`
curl -f -s http://localhost:$fe_http_port/api/health
be_http_port=`get_be_http_port`
curl -f -s http://localhost:$be_http_port/api/health

View File

@ -20,6 +20,7 @@ MYCNF=$SR_HOME/director/my.cnf
source $FE_HOME/bin/common.sh
PREVIOUS_FQDN=
CURRENT_FQDN=`hostname -f`
BOOTSTRAP_DONE_FILE=$SR_HOME/bootstrap_done
PASSWD_ERROR_MSG="Password error, stop retrying!
If the root user password is changed, please re-run the container with '-e MYSQL_PWD=<root_password>'"
@ -183,6 +184,8 @@ check_and_add_be()
done
}
# remove the flag file
rm -f $BOOTSTRAP_DONE_FILE
loginfo "checking if need to perform auto registring Backend ..."
check_fe_fqdn_mismatch
check_fe_liveness
@ -196,6 +199,9 @@ loginfo "StarRocks Cluster information details:"
exec_sql_with_column 'SHOW FRONTENDS\G'
exec_sql_with_column 'SHOW BACKENDS\G'
# touch the flag file
touch $BOOTSTRAP_DONE_FILE
loginfo
loginfo
loginfo "$PERSISTENT_MSG"