From e484fcc8c370898eda8fedfaface3046a932a3d2 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Wed, 10 Nov 2021 21:13:39 +0100 Subject: [PATCH] chore(bin/emqx): write sensible log if node not initialized --- bin/emqx | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/bin/emqx b/bin/emqx index fb62aac0c..070f4bd7f 100755 --- a/bin/emqx +++ b/bin/emqx @@ -431,6 +431,22 @@ wait_for() { done } +latest_vm_args() { + local hint_var_name="$1" + local vm_args_file + vm_args_file="$(find "$CONFIGS_DIR" -type f -name "vm.*.args" | sort | tail -1)" + if [ -f "$vm_args_file" ]; then + echo "$vm_args_file" + else + echoerr "ERRRO: node not initialized?" + echoerr "Generated config file vm.*.args is not found for command '$COMMAND'" + echoerr "in config dir: $CONFIGS_DIR" + echoerr "In case the file has been deleted while the node is running," + echoerr "set environment variable '$hint_var_name' to continue" + exit 1 + fi +} + ## IS_BOOT_COMMAND is set for later to inspect node name and cookie from hocon config (or env variable) case "${COMMAND}" in start|console|console_clean|foreground) @@ -452,10 +468,8 @@ if [ -z "$NAME" ]; then # for boot commands, inspect emqx.conf for node name NAME="$(call_hocon -s $SCHEMA_MOD -I "$CONFIGS_DIR/" -c "$RUNNER_ETC_DIR"/emqx.conf get node.name | tr -d \")" else - # for non-boot commands, inspect vm.