Skip to content

Commit

Permalink
Optimizing Docker Log Output (openimsdk#2018)
Browse files Browse the repository at this point in the history
* Optimize script logs

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection

* Optimizing Docker Log Output Detection
  • Loading branch information
skiffer-git authored Mar 7, 2024
1 parent 38f685b commit 39647b3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions scripts/check-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
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
if openim::util::is_running_in_container; then
exec >> ${DOCKER_LOG_FILE} 2>&1
fi


Expand Down Expand Up @@ -75,7 +75,7 @@ if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then
openim::color::echo ${COLOR_CYAN} "Environment in the interior of the container"
else
openim::color::echo ${COLOR_CYAN} "The environment is outside the container"
openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]} || return 0
openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}
fi

if [[ $? -ne 0 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi
LOG_FILE="${OPENIM_OUTPUT}/logs/openim-$(date '+%Y%m%d').log"
STDERR_LOG_FILE="${OPENIM_OUTPUT}/logs/openim-error-$(date '+%Y%m%d').log"
TMP_LOG_FILE="${OPENIM_OUTPUT}/logs/openim-tmp-$(date '+%Y%m%d').log"

DOCKER_LOG_FILE="${OPENIM_OUTPUT}/logs/openim-docker.log"
if [[ ! -d "${OPENIM_OUTPUT}/logs" ]]; then
mkdir -p "${OPENIM_OUTPUT}/logs"
touch "$LOG_FILE"
Expand Down
9 changes: 9 additions & 0 deletions scripts/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2866,6 +2866,15 @@ function openim::util::gen_os_arch() {



function openim::util::is_running_in_container() {
if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then
return 0
else
return 1
fi
}


function openim::util::check_process_names_for_stop() {
local all_stopped=true
for service in "${OPENIM_ALL_SERVICE_LIBRARIES[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion scripts/start-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function execute_start_scripts() {



if grep -q docker /proc/1/cgroup; then
if openim::util::is_running_in_container; then
exec > ${DOCKER_LOG_FILE} 2>&1
fi

Expand Down

0 comments on commit 39647b3

Please sign in to comment.