dengzhhu653 commented on code in PR #3386:
URL: https://github.com/apache/hive/pull/3386#discussion_r908012977
##########
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}
Review Comment:
picking from hive-site.xml for `timeout` is more elegant, I searched through
xml apis for this purpose, but did not have an answer, another consideration is
that one may not even configure the `timeout` in hive-site.xml, so here give a
hardcoded default value(30min), and can be changed via `bin/hive --service
hiveserver2 --graceful_stop <pid> <timeout>`.
--
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]