feat: inspect parent pid if emqx pid enters defunct state

This commit is contained in:
Zaiming Shi 2021-08-09 23:32:56 +02:00
parent 1a80b9dc47
commit 31b1646611
1 changed files with 9 additions and 2 deletions

View File

@ -303,7 +303,15 @@ bootstrapd() {
is_down() { is_down() {
PID="$1" PID="$1"
if ps -p "$PID" >/dev/null; then if ps -p "$PID" >/dev/null; then
# still alive # still around
# shellcheck disable=SC2009 # this grep pattern is not a part of the progra names
if ps -p "$PID" | grep -q 'defunct'; then
# zombie state, print parent pid
parent="$(ps -o ppid= -p "$PID" | tr -d ' ')"
echo "WARN: $PID is marked <defunct>, parent:"
ps -p "$parent"
return 0
fi
return 1 return 1
fi fi
# it's gone # it's gone
@ -487,7 +495,6 @@ case "$1" in
fi fi
WAIT_TIME="${WAIT_FOR_ERLANG_STOP:-60}" WAIT_TIME="${WAIT_FOR_ERLANG_STOP:-60}"
if ! wait_for "$WAIT_TIME" 'is_down' "$PID"; then if ! wait_for "$WAIT_TIME" 'is_down' "$PID"; then
ps -p "$PID"
msg="dangling after ${WAIT_TIME} seconds" msg="dangling after ${WAIT_TIME} seconds"
# also log to syslog # also log to syslog
logger -t "${REL_NAME}[${PID}]" "STOP: $msg" logger -t "${REL_NAME}[${PID}]" "STOP: $msg"