[KYUUBI #6593] bin/kyuubi supports kill command

# 🔍 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 🔖

- [ ] 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 🎉
```
(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 <yao@apache.org>
Signed-off-by: Kent Yao <yao@apache.org>
This commit is contained in:
Bruce Wong 2024-08-13 20:01:47 +08:00 committed by Kent Yao
parent cd390ba980
commit d2ead6bb24
No known key found for this signature in database
GPG Key ID: F7051850A0AF904D

View File

@ -26,6 +26,7 @@ function usage() {
echo " restart - Restart Kyuubi server as a daemon" echo " restart - Restart Kyuubi server as a daemon"
echo " run - Run a Kyuubi server in the foreground" echo " run - Run a Kyuubi server in the foreground"
echo " stop - Stop the Kyuubi daemon" echo " stop - Stop the Kyuubi daemon"
echo " kill - Stop the Kyuubi daemon forcefully"
echo " status - Show status of the Kyuubi daemon" echo " status - Show status of the Kyuubi daemon"
echo " -h | --help - Show this help message" echo " -h | --help - Show this help message"
} }
@ -107,7 +108,7 @@ if [[ -n ${YARN_CONF_DIR} ]]; then
KYUUBI_CLASSPATH="${KYUUBI_CLASSPATH}:${YARN_CONF_DIR}" KYUUBI_CLASSPATH="${KYUUBI_CLASSPATH}:${YARN_CONF_DIR}"
fi fi
if [[ "$1" =~ ^(start|restart|run|stop|status)$ ]]; then if [[ "$1" =~ ^(start|restart|run|stop|kill|status)$ ]]; then
command=$1 command=$1
shift shift
fi fi
@ -215,6 +216,18 @@ function stop_kyuubi() {
fi 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() { function check_kyuubi() {
if [[ -f ${pid} ]]; then if [[ -f ${pid} ]]; then
TARGET_ID="$(cat "$pid")" TARGET_ID="$(cat "$pid")"
@ -247,6 +260,10 @@ case $command in
stop_kyuubi stop_kyuubi
;; ;;
(kill)
kill_kyuubi
;;
(status) (status)
check_kyuubi check_kyuubi
;; ;;