From 38f685bd01b793d49d5d4e1cdc9b95500662dedf Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Thu, 7 Mar 2024 12:24:45 +0800 Subject: [PATCH] Optimizing Docker Log Output Detection (#2014) * Optimize script logs * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection --- scripts/check-all.sh | 5 +++++ scripts/docker-start-all.sh | 10 +--------- scripts/lib/logging.sh | 6 ++++++ scripts/start-all.sh | 8 ++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index a9b07d65b..1d05f838b 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -26,6 +26,11 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" +if grep -q docker /proc/1/cgroup; then + exec > ${DOCKER_LOG_FILE} 2>&1 +fi + + OPENIM_VERBOSE=4 openim::log::info "\n# Begin to check all openim service" diff --git a/scripts/docker-start-all.sh b/scripts/docker-start-all.sh index c47069e3b..4c9b7308f 100755 --- a/scripts/docker-start-all.sh +++ b/scripts/docker-start-all.sh @@ -23,15 +23,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" - openim::log::info "\n# Use Docker to start all openim service" - trap 'openim::util::onCtrlC' INT - "${OPENIM_ROOT}"/scripts/start-all.sh - -sleep 5 - -"${OPENIM_ROOT}"/scripts/check-all.sh - -tail -f ${LOG_FILE} +tail -f ${DOCKER_LOG_FILE} diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 8d017b077..0d5113541 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -36,6 +36,12 @@ if [[ ! -d "${OPENIM_OUTPUT}/logs" ]]; then touch "$TMP_LOG_FILE" fi +if [[ ! -f "$DOCKER_LOG_FILE" ]]; then + touch "$DOCKER_LOG_FILE" +fi + + + # Define the logging function function echo_log() { if $ENABLE_LOGGING; then diff --git a/scripts/start-all.sh b/scripts/start-all.sh index c27f2010c..fcf9496cc 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -17,12 +17,17 @@ #FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array. +#!/bin/bash + + + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" + # Function to execute the scripts. function execute_start_scripts() { for script_path in "${OPENIM_SERVER_SCRIPT_START_LIST[@]}"; do @@ -57,6 +62,9 @@ function execute_start_scripts() { +if grep -q docker /proc/1/cgroup; then + exec > ${DOCKER_LOG_FILE} 2>&1 +fi