Skip to content

Commit

Permalink
[KYUUBI #4515] Capturing process id for kyuubi server launched using …
Browse files Browse the repository at this point in the history
…run command
  • Loading branch information
Madhukar98 committed Oct 26, 2024
1 parent d3520dd commit c4ec781
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bin/kyuubi
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,20 @@ cmd="${RUNNER} ${KYUUBI_JAVA_OPTS} -cp ${KYUUBI_CLASSPATH} $CLASS $@"

pid="${KYUUBI_PID_DIR}/kyuubi-$USER-$CLASS.pid"

function get_pid(){
if [[ ! -w ${KYUUBI_PID_DIR} ]]; then
echo "${USER} does not have 'w' permission to ${KYUUBI_PID_DIR}"
exit 1
fi

run_pid="$(ps -ef | grep kyuubi | grep java | grep -v grep | awk '{print $2}')"
if [[ -n $run_pid ]]; then
echo "$run_pid" > "$pid"
fi
}

function start_kyuubi() {
get_pid
if [[ ! -w ${KYUUBI_PID_DIR} ]]; then
echo "${USER} does not have 'w' permission to ${KYUUBI_PID_DIR}"
exit 1
Expand Down Expand Up @@ -167,6 +180,14 @@ function start_kyuubi() {
}

function run_kyuubi() {
if [ -f "$pid" ]; then
TARGET_ID="$(cat "$pid")"
if [[ $(ps -p "$TARGET_ID" -o comm=) =~ "java" ]]; then
echo "$CLASS running as process $TARGET_ID Stop it first."
exit 1
fi
fi

echo "Starting $CLASS"
exec nice -n "${KYUUBI_NICENESS:-0}" ${cmd}
}
Expand Down Expand Up @@ -229,6 +250,7 @@ function kill_kyuubi() {
}

function check_kyuubi() {
get_pid
if [[ -f ${pid} ]]; then
TARGET_ID="$(cat "$pid")"
if [[ $(ps -p "$TARGET_ID" -o comm=) =~ "java" ]]; then
Expand Down

0 comments on commit c4ec781

Please sign in to comment.