refactor: export EMQX_LOG_DIR

This commit is contained in:
Zaiming (Stone) Shi 2023-04-27 16:29:25 +02:00
parent a1551213c8
commit 41f13330ba
4 changed files with 13 additions and 12 deletions

View File

@ -1199,7 +1199,7 @@ log_handler_common_confs(Enable) ->
]. ].
crash_dump_file_default() -> crash_dump_file_default() ->
case os:getenv("RUNNER_LOG_DIR") of case os:getenv("EMQX_LOG_DIR") of
false -> false ->
%% testing, or running emqx app as deps %% testing, or running emqx app as deps
<<"log/erl_crash.dump">>; <<"log/erl_crash.dump">>;

View File

@ -304,7 +304,7 @@ if [ "$ES" -ne 0 ]; then
fi fi
# Make sure log directory exists # Make sure log directory exists
mkdir -p "$RUNNER_LOG_DIR" mkdir -p "$EMQX_LOG_DIR"
# turn off debug as this is static # turn off debug as this is static
set +x set +x
@ -757,7 +757,7 @@ generate_config() {
local node_name="$2" local node_name="$2"
## Delete the *.siz files first or it can't start after ## Delete the *.siz files first or it can't start after
## changing the config 'log.rotation.size' ## changing the config 'log.rotation.size'
rm -f "${RUNNER_LOG_DIR}"/*.siz rm -f "${EMQX_LOG_DIR}"/*.siz
## timestamp for each generation ## timestamp for each generation
local NOW_TIME local NOW_TIME
@ -979,7 +979,7 @@ diagnose_boot_failure_and_die() {
local ps_line local ps_line
ps_line="$(find_emqx_process)" ps_line="$(find_emqx_process)"
if [ -z "$ps_line" ]; then if [ -z "$ps_line" ]; then
echo "Find more information in the latest log file: ${RUNNER_LOG_DIR}/erlang.log.*" echo "Find more information in the latest log file: ${EMQX_LOG_DIR}/erlang.log.*"
exit 1 exit 1
fi fi
if ! relx_nodetool "ping" > /dev/null; then if ! relx_nodetool "ping" > /dev/null; then
@ -990,7 +990,7 @@ diagnose_boot_failure_and_die() {
fi fi
if ! relx_nodetool 'eval' 'true = emqx:is_running()' > /dev/null; then if ! relx_nodetool 'eval' 'true = emqx:is_running()' > /dev/null; then
logerr "$NAME node is started, but failed to complete the boot sequence in time." logerr "$NAME node is started, but failed to complete the boot sequence in time."
echo "Please collect the logs in ${RUNNER_LOG_DIR} and report a bug to EMQX team at https://github.com/emqx/emqx/issues/new/choose" echo "Please collect the logs in ${EMQX_LOG_DIR} and report a bug to EMQX team at https://github.com/emqx/emqx/issues/new/choose"
pipe_shutdown pipe_shutdown
exit 3 exit 3
fi fi
@ -1065,7 +1065,7 @@ case "${COMMAND}" in
mkdir -p "$PIPE_DIR" mkdir -p "$PIPE_DIR"
"$BINDIR/run_erl" -daemon "$PIPE_DIR" "$RUNNER_LOG_DIR" \ "$BINDIR/run_erl" -daemon "$PIPE_DIR" "$EMQX_LOG_DIR" \
"$(relx_start_command)" "$(relx_start_command)"
WAIT_TIME=${EMQX_WAIT_FOR_START:-120} WAIT_TIME=${EMQX_WAIT_FOR_START:-120}

View File

@ -10,10 +10,10 @@ echo "Running node dump in ${RUNNER_ROOT_DIR}"
cd "${RUNNER_ROOT_DIR}" cd "${RUNNER_ROOT_DIR}"
DUMP="$RUNNER_LOG_DIR/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz" DUMP="$EMQX_LOG_DIR/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz"
CONF_DUMP="$RUNNER_LOG_DIR/conf.dump" CONF_DUMP="$EMQX_LOG_DIR/conf.dump"
LICENSE_INFO="$RUNNER_LOG_DIR/license_info.txt" LICENSE_INFO="$EMQX_LOG_DIR/license_info.txt"
SYSINFO="$RUNNER_LOG_DIR/sysinfo.txt" SYSINFO="$EMQX_LOG_DIR/sysinfo.txt"
LOG_MAX_AGE_DAYS=3 LOG_MAX_AGE_DAYS=3
@ -74,7 +74,7 @@ done
# Pack files # Pack files
{ {
find "$RUNNER_LOG_DIR" -mtime -"${LOG_MAX_AGE_DAYS}" \( -name '*.log.*' -or -name 'run_erl.log*' \) find "$EMQX_LOG_DIR" -mtime -"${LOG_MAX_AGE_DAYS}" \( -name '*.log.*' -or -name 'run_erl.log*' \)
echo "${SYSINFO}" echo "${SYSINFO}"
echo "${CONF_DUMP}" echo "${CONF_DUMP}"
echo "${LICENSE_INFO}" echo "${LICENSE_INFO}"

View File

@ -11,7 +11,8 @@ RUNNER_LIB_DIR="{{ runner_lib_dir }}"
IS_ELIXIR="${IS_ELIXIR:-{{ is_elixir }}}" IS_ELIXIR="${IS_ELIXIR:-{{ is_elixir }}}"
## Allow users to pre-set `EMQX_LOG_DIR` because it only affects boot commands like `start` and `console`, ## Allow users to pre-set `EMQX_LOG_DIR` because it only affects boot commands like `start` and `console`,
## but not other commands such as `ping` and `ctl`. ## but not other commands such as `ping` and `ctl`.
RUNNER_LOG_DIR="${EMQX_LOG_DIR:-${RUNNER_LOG_DIR:-{{ runner_log_dir }}}}" ## RUNNER_LOG_DIR is kept for backward compatibility.
export EMQX_LOG_DIR="${EMQX_LOG_DIR:-${RUNNER_LOG_DIR:-{{ runner_log_dir }}}}"
EMQX_ETC_DIR="{{ emqx_etc_dir }}" EMQX_ETC_DIR="{{ emqx_etc_dir }}"
RUNNER_USER="{{ runner_user }}" RUNNER_USER="{{ runner_user }}"
SCHEMA_MOD="{{ emqx_schema_mod }}" SCHEMA_MOD="{{ emqx_schema_mod }}"