HBASE-27651 hbase-daemon.sh foreground_start should propagate SIGHUP and SIGTERM
Introduce separate `trap`s for SIGHUP vs. the rest. Treat `SIGINT`, `SIGKILL`, and `EXIT` identically, as before. Use the signal name without `SIG` prefix for increased portability, as per the POSIX man page for `trap`. `SIGTERM` handler will now honor `HBASE_STOP_TIMEOUT` as described in the file header. Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
parent
873f8987f1
commit
e7a958a45f
|
@ -78,22 +78,34 @@ hbase_rotate_log ()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanAfterRun() {
|
function sighup_handler
|
||||||
if [ -f ${HBASE_PID} ]; then
|
{
|
||||||
# If the process is still running time to tear it down.
|
# pass through SIGHUP if we can
|
||||||
kill -9 `cat ${HBASE_PID}` > /dev/null 2>&1
|
if [ -f "${HBASE_PID}" ] ; then
|
||||||
rm -f ${HBASE_PID} > /dev/null 2>&1
|
kill -s HUP "$(cat "${HBASE_PID}")"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ -f ${HBASE_ZNODE_FILE} ]; then
|
function sigterm_handler
|
||||||
if [ "$command" = "master" ]; then
|
{
|
||||||
HBASE_OPTS="$HBASE_OPTS $HBASE_MASTER_OPTS" $bin/hbase master clear > /dev/null 2>&1
|
if [ -f "${HBASE_PID}" ]; then
|
||||||
|
kill -s TERM "$(cat "${HBASE_PID}")"
|
||||||
|
waitForProcessEnd "$(cat "${HBASE_PID}")" "${command}"
|
||||||
|
fi
|
||||||
|
cleanAfterRun
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanAfterRun() {
|
||||||
|
rm -f "${HBASE_PID}" > /dev/null 2>&1
|
||||||
|
if [ -f "${HBASE_ZNODE_FILE}" ]; then
|
||||||
|
if [ "${command}" = "master" ]; then
|
||||||
|
HBASE_OPTS="$HBASE_OPTS $HBASE_MASTER_OPTS" "${bin}/hbase" master clear > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
#call ZK to delete the node
|
# call ZK to delete the node
|
||||||
ZNODE=`cat ${HBASE_ZNODE_FILE}`
|
ZNODE="$(cat "${HBASE_ZNODE_FILE}")"
|
||||||
HBASE_OPTS="$HBASE_OPTS $HBASE_REGIONSERVER_OPTS" $bin/hbase zkcli delete ${ZNODE} > /dev/null 2>&1
|
HBASE_OPTS="$HBASE_OPTS $HBASE_REGIONSERVER_OPTS" "${bin}/hbase" zkcli delete "${ZNODE}" > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
rm ${HBASE_ZNODE_FILE}
|
rm -f "${HBASE_ZNODE_FILE}" > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +237,9 @@ case $startStop in
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(foreground_start)
|
(foreground_start)
|
||||||
trap cleanAfterRun SIGHUP SIGINT SIGTERM EXIT
|
trap sighup_handler HUP
|
||||||
|
trap sigterm_handler INT TERM EXIT
|
||||||
|
|
||||||
if [ "$HBASE_NO_REDIRECT_LOG" != "" ]; then
|
if [ "$HBASE_NO_REDIRECT_LOG" != "" ]; then
|
||||||
# NO REDIRECT
|
# NO REDIRECT
|
||||||
echo "`date` Starting $command on `hostname`"
|
echo "`date` Starting $command on `hostname`"
|
||||||
|
|
Loading…
Reference in New Issue