From 58529b4729793b4bcfe8c7ca2c5b0347191d77d3 Mon Sep 17 00:00:00 2001 From: yagagagaga Date: Thu, 23 Jan 2025 14:55:17 +0800 Subject: [PATCH] [chore](bash) optimize output information when doris_cloud startup (#45883) before: ``` bash bin/start.sh --daemon --meta-service LIBHDFS3_CONF= starts doris_cloud with args: --meta-service wait and check doris_cloud start successfully successfully started brpc listening on port=5000 time_elapsed_ms=11 doris_cloud start successfully ``` after: ``` bash bin/start.sh --daemon --meta-service 2024-12-26 15:31:53 start with args: --meta-service wait and check MetaService and Recycler start successfully process working directory: "/mnt/disk1/zhangminke/ms" pid=1666015 written to file=./bin/doris_cloud.pid version:{doris-0.0.0-release} code_version:{commit=fd44740fadabebfedb5da201d7ce427a5dd47c44 time=2025-01-16 18:53:00 +0800} build_info:{initiator=zhangminke@VM-10-6-centos build_at=2025-01-16 18:53:00 +0800 build_on=NAME="TencentOS Server" VERSION="3.1 (Final)" } use volatile mem kv, please make sure it is not a production environment MetaService has been started successfully successfully started service listening on port=23415 time_elapsed_ms=19 ``` --- cloud/script/start.sh | 37 ++++++++++++++++++++++++++++--------- cloud/src/main.cpp | 10 +++++----- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/cloud/script/start.sh b/cloud/script/start.sh index ecb5a3b2bed1e6..9e906d5162d450 100644 --- a/cloud/script/start.sh +++ b/cloud/script/start.sh @@ -35,6 +35,8 @@ fi RUN_DAEMON=0 RUN_VERSION=0 RUN_CONSOLE=0 +RUN_METASERVICE=0 +RUN_RECYCLYER=0 for arg; do shift [[ "${arg}" = "--daemonized" ]] && RUN_DAEMON=1 && continue @@ -42,8 +44,16 @@ for arg; do [[ "${arg}" = "--daemon" ]] && RUN_DAEMON=1 && continue [[ "${arg}" = "--version" ]] && RUN_VERSION=1 && continue [[ "${arg}" = "--console" ]] && RUN_CONSOLE=1 && continue + [[ "${arg}" = "--meta-service" ]] && RUN_METASERVICE=1 && continue + [[ "${arg}" = "--recycler" ]] && RUN_RECYCLYER=1 && continue set -- "$@" "${arg}" done +if [[ ${RUN_METASERVICE} -eq 1 ]]; then + set -- "$@" "--meta-service" +fi +if [[ ${RUN_RECYCLYER} -eq 1 ]]; then + set -- "$@" "--recycler" +fi # echo "$@" "daemonized=${daemonized}"} # export env variables from doris_cloud.conf @@ -60,13 +70,23 @@ while read -r line; do fi done <"${DORIS_HOME}/conf/doris_cloud.conf" +role='' +if [[ ${RUN_METASERVICE} -eq 0 ]] && [[ ${RUN_RECYCLYER} -eq 0 ]]; then + role='MetaService and Recycler' +elif [[ ${RUN_METASERVICE} -eq 1 ]] && [[ ${RUN_RECYCLYER} -eq 0 ]]; then + role='MetaService' +elif [[ ${RUN_METASERVICE} -eq 0 ]] && [[ ${RUN_RECYCLYER} -eq 1 ]]; then + role='Recycler' +elif [[ ${RUN_METASERVICE} -eq 1 ]] && [[ ${RUN_RECYCLYER} -eq 1 ]]; then + role='MetaService and Recycler' +fi process=doris_cloud if [[ ${RUN_VERSION} -eq 0 ]] && [[ -f "${DORIS_HOME}/bin/${process}.pid" ]]; then pid=$(cat "${DORIS_HOME}/bin/${process}.pid") if [[ "${pid}" != "" ]]; then if kill -0 "$(cat "${DORIS_HOME}/bin/${process}.pid")" >/dev/null 2>&1; then - echo "pid file existed, ${process} have already started, pid=${pid}" + echo "pid file existed, ${role} have already started, pid=${pid}" exit 1 fi fi @@ -113,7 +133,7 @@ if [[ -f "${DORIS_HOME}/conf/hdfs-site.xml" ]]; then export LIBHDFS3_CONF="${DORIS_HOME}/conf/hdfs-site.xml" fi -echo "LIBHDFS3_CONF=${LIBHDFS3_CONF}" +# echo "LIBHDFS3_CONF=${LIBHDFS3_CONF}" # to enable dump jeprof heap stats prodigally, change `prof_active:false` to `prof_active:true` or curl http://be_host:be_webport/jeheap/prof/true # to control the dump interval change `lg_prof_interval` to a specific value, it is pow/exponent of 2 in size of bytes, default 34 means 2 ** 34 = 16GB @@ -126,26 +146,25 @@ if [[ "${RUN_VERSION}" -ne 0 ]]; then fi mkdir -p "${DORIS_HOME}/log" -echo "starts ${process} with args: $*" +echo "$(date +'%F %T') start with args: $*" out_file=${DORIS_HOME}/log/${process}.out if [[ "${RUN_DAEMON}" -eq 1 ]]; then # append 10 blank lines to ensure the following tail -n10 works correctly printf "\n\n\n\n\n\n\n\n\n\n" >>"${out_file}" - echo "$(date +'%F %T') try to start ${process}" >>"${out_file}" + echo "$(date +'%F %T') start with args: $*" >>"${out_file}" nohup "${bin}" "$@" >>"${out_file}" 2>&1 & - echo "wait and check ${process} start successfully" + echo "wait and check ${role} start successfully" >>"${out_file}" sleep 3 - tail -n10 "${out_file}" | grep 'successfully started brpc' + tail -n12 "${out_file}" | grep 'successfully started service' ret=$? if [[ ${ret} -ne 0 ]]; then - echo "${process} may not start successfully please check process log for more details" + echo "${role} may not start successfully please check process log for more details" exit 1 fi - echo "${process} start successfully" + tail -n12 "${out_file}" exit 0 elif [[ "${RUN_CONSOLE}" -eq 1 ]]; then export DORIS_LOG_TO_STDERR=1 - date "${bin}" "$@" 2>&1 else "${bin}" "$@" diff --git a/cloud/src/main.cpp b/cloud/src/main.cpp index 2ea251a2d2abf0..32667d0e1a2478 100644 --- a/cloud/src/main.cpp +++ b/cloud/src/main.cpp @@ -221,7 +221,7 @@ int main(int argc, char** argv) { // We can invoke glog from now on std::string msg; - LOG(INFO) << "try to start doris_cloud"; + LOG(INFO) << "try to start " << process_name; LOG(INFO) << build_info(); std::cout << build_info() << std::endl; @@ -230,7 +230,7 @@ int main(int argc, char** argv) { std::get<0>(args.args()[ARG_RECYCLER]) = true; LOG(INFO) << "meta_service and recycler are both not specified, " "run doris_cloud as meta_service and recycler by default"; - std::cout << "run doris_cloud as meta_service and recycler by default" << std::endl; + std::cout << "try to start meta_service, recycler" << std::endl; } brpc::Server server; @@ -282,7 +282,7 @@ int main(int argc, char** argv) { std::cerr << msg << std::endl; return ret; } - msg = "meta-service started"; + msg = "MetaService has been started successfully"; LOG(INFO) << msg; std::cout << msg << std::endl; } @@ -295,7 +295,7 @@ int main(int argc, char** argv) { std::cerr << msg << std::endl; return ret; } - msg = "recycler started"; + msg = "Recycler has been started successfully"; LOG(INFO) << msg; std::cout << msg << std::endl; auto periodiccally_log = [&]() { @@ -324,7 +324,7 @@ int main(int argc, char** argv) { return -1; } end = steady_clock::now(); - msg = "successfully started brpc listening on port=" + std::to_string(port) + + msg = "successfully started service listening on port=" + std::to_string(port) + " time_elapsed_ms=" + std::to_string(duration_cast(end - start).count()); LOG(INFO) << msg; std::cout << msg << std::endl;