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() ->
case os:getenv("RUNNER_LOG_DIR") of
case os:getenv("EMQX_LOG_DIR") of
false ->
%% testing, or running emqx app as deps
<<"log/erl_crash.dump">>;

View File

@ -304,7 +304,7 @@ if [ "$ES" -ne 0 ]; then
fi
# Make sure log directory exists
mkdir -p "$RUNNER_LOG_DIR"
mkdir -p "$EMQX_LOG_DIR"
# turn off debug as this is static
set +x
@ -757,7 +757,7 @@ generate_config() {
local node_name="$2"
## Delete the *.siz files first or it can't start after
## changing the config 'log.rotation.size'
rm -f "${RUNNER_LOG_DIR}"/*.siz
rm -f "${EMQX_LOG_DIR}"/*.siz
## timestamp for each generation
local NOW_TIME
@ -979,7 +979,7 @@ diagnose_boot_failure_and_die() {
local ps_line
ps_line="$(find_emqx_process)"
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
fi
if ! relx_nodetool "ping" > /dev/null; then
@ -990,7 +990,7 @@ diagnose_boot_failure_and_die() {
fi
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."
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
exit 3
fi
@ -1065,7 +1065,7 @@ case "${COMMAND}" in
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)"
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}"
DUMP="$RUNNER_LOG_DIR/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz"
CONF_DUMP="$RUNNER_LOG_DIR/conf.dump"
LICENSE_INFO="$RUNNER_LOG_DIR/license_info.txt"
SYSINFO="$RUNNER_LOG_DIR/sysinfo.txt"
DUMP="$EMQX_LOG_DIR/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz"
CONF_DUMP="$EMQX_LOG_DIR/conf.dump"
LICENSE_INFO="$EMQX_LOG_DIR/license_info.txt"
SYSINFO="$EMQX_LOG_DIR/sysinfo.txt"
LOG_MAX_AGE_DAYS=3
@ -74,7 +74,7 @@ done
# 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 "${CONF_DUMP}"
echo "${LICENSE_INFO}"

View File

@ -11,7 +11,8 @@ RUNNER_LIB_DIR="{{ runner_lib_dir }}"
IS_ELIXIR="${IS_ELIXIR:-{{ is_elixir }}}"
## 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`.
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 }}"
RUNNER_USER="{{ runner_user }}"
SCHEMA_MOD="{{ emqx_schema_mod }}"