From d2ead6bb243996f86d5f7f7475cadd3bc2c5dfd8 Mon Sep 17 00:00:00 2001 From: Bruce Wong <603334301@qq.com> Date: Tue, 13 Aug 2024 20:01:47 +0800 Subject: [PATCH] [KYUUBI #6593] `bin/kyuubi` supports `kill` command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # :mag: Description ## Issue References ๐Ÿ”— This pull request fixes #6593 ## Describe Your Solution ๐Ÿ”ง The `kill -9 $PID` command directly forces Kyuubi to be shut down. ## Types of changes :bookmark: - [ ] Bugfix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan ๐Ÿงช #### Behavior With This Pull Request :tada: ``` (base) $ bin/kyuubi kill Stopping org.apache.kyuubi.server.KyuubiServer forcefully. __ __ __ /` \/` \ /` \ __ \ \ \/ / __ __ __ __ __ __\ \ \____ /\_\ \ \ , < /` \/` \/` \/` \/` \/` \\ \ \__` \/` \ \ \ \ \`\\ \ \_\ \\ \_\ \\ \_\ \\ \ \L\ \ \ \ \ \_\ \_ \/`____ \ \____/ \ \____`\ \_,__/ \ \_\ \/_/\/_/ `/___/> \/___/ \/___/ \/___/ \/_/ /\___/ \/__\/ Bye! ``` --- # Checklist ๐Ÿ“ - [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6611 from BruceWong96/kyuubi_kill_command. Closes #6593 00f8c4c59 [Kent Yao] Update bin/kyuubi b27cd1a43 [Bruce Wong] fix indent. d2f3fc44f [Bruce Wong] add kyuubi kill command. Lead-authored-by: Bruce Wong <603334301@qq.com> Co-authored-by: Kent Yao Signed-off-by: Kent Yao --- bin/kyuubi | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/kyuubi b/bin/kyuubi index 7dd5bb4ee..da4f96a3e 100755 --- a/bin/kyuubi +++ b/bin/kyuubi @@ -26,6 +26,7 @@ function usage() { echo " restart - Restart Kyuubi server as a daemon" echo " run - Run a Kyuubi server in the foreground" echo " stop - Stop the Kyuubi daemon" + echo " kill - Stop the Kyuubi daemon forcefully" echo " status - Show status of the Kyuubi daemon" echo " -h | --help - Show this help message" } @@ -107,7 +108,7 @@ if [[ -n ${YARN_CONF_DIR} ]]; then KYUUBI_CLASSPATH="${KYUUBI_CLASSPATH}:${YARN_CONF_DIR}" fi -if [[ "$1" =~ ^(start|restart|run|stop|status)$ ]]; then +if [[ "$1" =~ ^(start|restart|run|stop|kill|status)$ ]]; then command=$1 shift fi @@ -215,6 +216,18 @@ function stop_kyuubi() { fi } +function kill_kyuubi() { + if [ -f ${pid} ]; then + TARGET_ID="$(cat "$pid")" + echo "Stopping $CLASS forcefully." + kill -9 $TARGET_ID + kyuubi_logo + echo "Bye!" + else + echo "no $CLASS to stop" + fi +} + function check_kyuubi() { if [[ -f ${pid} ]]; then TARGET_ID="$(cat "$pid")" @@ -247,6 +260,10 @@ case $command in stop_kyuubi ;; + (kill) + kill_kyuubi + ;; + (status) check_kyuubi ;;