feat: add check_conf cli to check config format

This commit is contained in:
zhongwencool 2022-07-14 17:11:15 +08:00
parent d9c714153f
commit 87aeead653
2 changed files with 24 additions and 5 deletions

View File

@ -21,6 +21,7 @@ File format:
### Enhancements ### Enhancements
- HTTP API(GET /rules/) support for pagination and fuzzy filtering. [#8450] - HTTP API(GET /rules/) support for pagination and fuzzy filtering. [#8450]
- Add check_conf cli to check config format. [#8486]
## v4.3.16 ## v4.3.16

View File

@ -196,6 +196,7 @@ usage() {
echo " Up/Down-grade: upgrade | downgrade | install | uninstall" echo " Up/Down-grade: upgrade | downgrade | install | uninstall"
echo " Install info: ertspath | root_dir | versions" echo " Install info: ertspath | root_dir | versions"
echo " Runtime info: pid | ping | versions" echo " Runtime info: pid | ping | versions"
echo " Configure check: check_conf"
echo " Advanced: console_clean | escript | rpc | rpcterms | eval" echo " Advanced: console_clean | escript | rpc | rpcterms | eval"
echo '' echo ''
echo "Execute '$REL_NAME COMMAND help' for more information" echo "Execute '$REL_NAME COMMAND help' for more information"
@ -338,9 +339,12 @@ trim() {
# Function to generate app.config and vm.args # Function to generate app.config and vm.args
generate_config() { generate_config() {
## Delete the *.siz files first or it cann't start after check_only="$1"
## changing the config 'log.rotation.size' if [ "$check_only" != "check_only" ]; then
rm -rf "${RUNNER_LOG_DIR}"/*.siz ## Delete the *.siz files first or it cann't start after
## changing the config 'log.rotation.size'
rm -rf "${RUNNER_LOG_DIR}"/*.siz
fi
set +e set +e
if [ "${EMQX_LICENSE_CONF:-}" = "" ]; then if [ "${EMQX_LICENSE_CONF:-}" = "" ]; then
@ -392,15 +396,22 @@ generate_config() {
fi fi
fi fi
done done
mv -f "$TMP_ARG_FILE" "$CUTTLE_GEN_ARG_FILE"
if ! relx_nodetool chkconfig -config "$CONFIG_FILE"; then if ! relx_nodetool chkconfig -config "$CONFIG_FILE"; then
echoerr "Error reading $CONFIG_FILE" echoerr "Error reading $CONFIG_FILE"
exit 1 exit 1
fi fi
if [ "$check_only" = "check_only" ]; then
rm -rf "$TMP_ARG_FILE"
rm -rf "$CUTTLE_GEN_ARG_FILE"
rm -rf "$CONFIG_FILE"
else
mv -f "$TMP_ARG_FILE" "$CUTTLE_GEN_ARG_FILE"
fi
} }
# Call bootstrapd for daemon commands like start/stop/console # Call bootstrap for daemon commands like start/stop/console
bootstrapd() { bootstrapd() {
if [ -e "$RUNNER_DATA_DIR/.erlang.cookie" ]; then if [ -e "$RUNNER_DATA_DIR/.erlang.cookie" ]; then
chown "$RUNNER_USER" "$RUNNER_DATA_DIR"/.erlang.cookie chown "$RUNNER_USER" "$RUNNER_DATA_DIR"/.erlang.cookie
@ -451,6 +462,9 @@ case "$1" in
foreground) foreground)
IS_BOOT_COMMAND='yes' IS_BOOT_COMMAND='yes'
;; ;;
check_conf)
IS_BOOT_COMMAND='yes'
;;
esac esac
@ -819,6 +833,10 @@ case "$1" in
ertspath) ertspath)
echo "$ERTS_PATH" echo "$ERTS_PATH"
;; ;;
check_conf)
generate_config "check_only"
echo "$RUNNER_ETC_DIR/emqx.conf is ok"
;;
ctl) ctl)
assert_node_alive assert_node_alive