Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KYUUBI #4515] Capturing process id for kyuubi server launched using run command #6374

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bin/kyuubi
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ cmd="${RUNNER} ${KYUUBI_JAVA_OPTS} -cp ${KYUUBI_CLASSPATH} $CLASS $@"

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

function get_pid(){
run_pid="$(ps -ef | grep org.apache.kyuubi.server.KyuubiServer |
grep java | grep "$KYUUBI_CONF_DIR" | grep -v grep | awk '{print $2}')"
if [[ -n $run_pid ]]; then
echo "$run_pid" > "$pid"
fi
}

function start_kyuubi() {
if [[ ! -w ${KYUUBI_PID_DIR} ]]; then
echo "${USER} does not have 'w' permission to ${KYUUBI_PID_DIR}"
Expand All @@ -128,6 +136,8 @@ function start_kyuubi() {
exit 1
fi

get_pid

if [ -f "$pid" ]; then
TARGET_ID="$(cat "$pid")"
if [[ $(ps -p "$TARGET_ID" -o comm=) =~ "java" ]]; then
Expand Down Expand Up @@ -167,6 +177,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 +247,12 @@ function kill_kyuubi() {
}

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

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