From 18fc82855b83faea4208777a96d98262446d1b62 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Thu, 28 Oct 2021 20:45:00 +0200 Subject: [PATCH 1/2] fix(bin/emqx): handle flags in vm.args prior to this fix, the flags such as -heart in vm.args file were taken as KEY="", VALUE="-heart" as a result, the sed replacement replaces all lines with "-heart" causing beam to crash at boot --- bin/emqx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/bin/emqx b/bin/emqx index e8fda9c2b..ff12afcac 100755 --- a/bin/emqx +++ b/bin/emqx @@ -238,12 +238,22 @@ generate_config() { sed '/^#/d' "$CUTTLE_GEN_ARG_FILE" | sed '/^$/d' | while IFS='' read -r ARG_LINE || [ -n "$ARG_LINE" ]; do ARG_KEY=$(echo "$ARG_LINE" | awk '{$NF="";print}') ARG_VALUE=$(echo "$ARG_LINE" | awk '{print $NF}') - TMP_ARG_VALUE=$(grep "^$ARG_KEY" "$TMP_ARG_FILE" | awk '{print $NF}') - if [ "$ARG_VALUE" != "$TMP_ARG_VALUE" ] ; then - if [ -n "$TMP_ARG_VALUE" ]; then - sh -c "$SED_REPLACE 's/^$ARG_KEY.*$/$ARG_LINE/' $TMP_ARG_FILE" - else - echo "$ARG_LINE" >> "$TMP_ARG_FILE" + if [ "$ARG_KEY" = '' ]; then + ## for the flags, e.g. -heart -emu_args etc + ARG_KEY=$(echo "$ARG_LINE" | awk '{print $1}') + ARG_VALUE='' + TMP_ARG_KEY=$(grep "^$ARG_KEY" "$TMP_ARG_FILE" | awk '{print $1}') + if [ "$TMP_ARG_KEY" = '' ]; then + echo "$ARG_KEY" >> "$TMP_ARG_FILE" + fi + else + TMP_ARG_VALUE=$(grep "^$ARG_KEY" "$TMP_ARG_FILE" | awk '{print $NF}') + if [ "$ARG_VALUE" != "$TMP_ARG_VALUE" ] ; then + if [ -n "$TMP_ARG_VALUE" ]; then + sh -c "$SED_REPLACE 's/^$ARG_KEY.*$/$ARG_LINE/' $TMP_ARG_FILE" + else + echo "$ARG_LINE" >> "$TMP_ARG_FILE" + fi fi fi done From cb3d2fd6c3269817de84f77c59415e12bdfb06f9 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Thu, 28 Oct 2021 21:08:07 +0200 Subject: [PATCH 2/2] chore: refine -heart option document --- etc/emqx.conf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/etc/emqx.conf b/etc/emqx.conf index 6043dc361..152f28215 100644 --- a/etc/emqx.conf +++ b/etc/emqx.conf @@ -199,6 +199,16 @@ node.data_dir = {{ platform_data_dir }} ## Heartbeat monitoring of an Erlang runtime system. Comment the line to disable ## heartbeat, or set the value as 'on' ## +## Turning this on may cause the node to restart if it becomes unresponsive to +## the heartbeat pings. +## +## NOTE: When managed by systemd (or other supervision tools like systemd), +## heart will probably only cause EMQ X to stop, but restart or not will +## depend on systemd's restart strategy. +## NOTE: When running in docker, the container will die as soon as the the +## heart process kills EMQ X, but restart or not will depend on container +## supervision strategy, such as k8s restartPolicy. +## ## Value: on ## ## vm.args: -heart