dengzhhu653 commented on code in PR #3386:
URL: https://github.com/apache/hive/pull/3386#discussion_r909334060
##########
bin/ext/hiveserver2.sh:
##########
@@ -16,24 +16,83 @@
THISSERVICE=hiveserver2
export SERVICE_LIST="${SERVICE_LIST}${THISSERVICE} "
+if [ "$HIVESERVER2_PID_DIR" = "" ]; then
+ HIVESERVER2_PID_DIR=$HIVE_CONF_DIR
+fi
+
+HIVESERVER2_PID=$HIVESERVER2_PID_DIR/hiveserver2.pid
+
+before_start() {
+ #ckeck if the process is not running
+ mkdir -p "$HIVESERVER2_PID_DIR"
+ if [ -f $HIVESERVER2_PID ]; then
+ if kill -0 $(cat $HIVESERVER2_PID) >/dev/null 2>&1; then
+ echo "HiveServer2 running as process $(cat $HIVESERVER2_PID). Stop it
first."
+ exit 1
+ fi
+ fi
+}
+
hiveserver2() {
- >&2 echo "$(timestamp): Starting HiveServer2"
- CLASS=org.apache.hive.service.server.HiveServer2
- if $cygwin; then
- HIVE_LIB=`cygpath -w "$HIVE_LIB"`
+ if [ "$1" = "--graceful_stop" ]; then
+ pid=$2
+ if [ "$pid" = "" -a -f $HIVESERVER2_PID ]; then
+ pid=$(cat $HIVESERVER2_PID)
+ fi
+ if [ "$pid" != "" ]; then
+ timeout=$3
+ killAndWait $pid ${timeout:-1800}
+ fi
+ else
+ before_start
+ echo >&2 "$(timestamp): Starting HiveServer2"
+ CLASS=org.apache.hive.service.server.HiveServer2
+ if $cygwin; then
+ HIVE_LIB=$(cygpath -w "$HIVE_LIB")
+ fi
+ JAR=${HIVE_LIB}/hive-service-[0-9].*.jar
+
+ export HADOOP_CLIENT_OPTS=" -Dproc_hiveserver2 $HADOOP_CLIENT_OPTS "
+ export HADOOP_OPTS="$HIVESERVER2_HADOOP_OPTS $HADOOP_OPTS"
+ hiveserver2_pid="$$"
Review Comment:
hiveserver2 also has other commands, such as `--deregister`, `--failover`,
those should be seperate from starting hiveserver2, otherwise they may also
write its pid into the same file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]