jerryshao commented on code in PR #4005:
URL: https://github.com/apache/gravitino/pull/4005#discussion_r1682780760


##########
bin/iceberg-rest-server.sh:
##########
@@ -0,0 +1,206 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#set -ex
+USAGE="-e Usage: bin/iceberg-rest-server.sh [--config <conf-dir>]\n\t
+        {start|run|stop|restart|status}"
+
+if [[ "$1" == "--config" ]]; then
+  shift
+  conf_dir="$1"
+  if [[ ! -d "${conf_dir}" ]]; then
+    echo "ERROR : ${conf_dir} is not a directory"
+    echo ${USAGE}
+    exit 1
+  else
+    export GRAVITINO_CONF_DIR="${conf_dir}"
+  fi
+  shift
+fi
+
+bin="$(dirname "${BASH_SOURCE-$0}")"
+bin="$(cd "${bin}">/dev/null; pwd)"
+
+. "${bin}/common.sh"
+
+check_java_version
+
+function check_process_status() {
+  local pid=$(found_iceberg_rest_server_pid)
+
+  if [[ -z "${pid}" ]]; then
+    echo "IcebergRESTServer is not running"
+  else
+    echo "IcebergRESTServer is running[PID:$pid]"
+  fi
+}
+
+function found_iceberg_rest_server_pid() {
+  process_name='IcebergRESTServer';
+  RUNNING_PIDS=$(ps x | grep ${process_name} | grep -v grep | awk '{print 
$1}');
+
+  if [[ -z "${RUNNING_PIDS}" ]]; then
+    return
+  fi
+
+  if ! kill -0 ${RUNNING_PIDS} > /dev/null 2>&1; then
+    echo "IcebergRESTServer running but process is dead"
+  fi
+
+  echo "${RUNNING_PIDS}"
+}
+
+function wait_for_iceberg_rest_server_to_die() {
+  timeout=10
+  timeoutTime=$(date "+%s")
+  let "timeoutTime+=$timeout"
+  currentTime=$(date "+%s")
+  forceKill=1
+
+  while [[ $currentTime -lt $timeoutTime ]]; do
+    local pid=$(found_iceberg_rest_server_pid)
+    if [[ -z "${pid}" ]]; then
+      forceKill=0
+      break
+    fi
+
+    $(kill ${pid} > /dev/null 2> /dev/null)
+    if kill -0 ${pid} > /dev/null 2>&1; then
+      sleep 3
+    else
+      forceKill=0
+      break
+    fi
+    currentTime=$(date "+%s")
+  done
+
+  if [[ forceKill -ne 0 ]]; then
+    $(kill -9 ${pid} > /dev/null 2> /dev/null)
+  fi
+}
+
+function start() {
+  local pid=$(found_iceberg_rest_server_pid)
+
+  if [[ ! -z "${pid}" ]]; then
+    if kill -0 ${pid} >/dev/null 2>&1; then
+      echo "IcebergRESTServer is already running"
+      return 0;
+    fi
+  fi
+
+  if [[ ! -d "${GRAVITINO_LOG_DIR}" ]]; then
+    echo "Log dir doesn't exist, create ${GRAVITINO_LOG_DIR}"
+    mkdir -p "${GRAVITINO_LOG_DIR}"
+  fi
+
+  nohup ${JAVA_RUNNER} ${JAVA_OPTS} ${GRAVITINO_DEBUG_OPTS} -cp 
${GRAVITINO_CLASSPATH} ${GRAVITINO_SERVER_NAME} >> "${GRAVITINO_OUTFILE}" 2>&1 &
+
+  pid=$!
+  if [[ -z "${pid}" ]]; then
+    echo "IcebergRESTServer start error!"
+    return 1;
+  else
+    echo "IcebergRESTServer start success!"
+  fi
+
+  sleep 2
+  check_process_status
+}
+
+function run() {
+  ${JAVA_RUNNER} ${JAVA_OPTS} ${GRAVITINO_DEBUG_OPTS} -cp 
${GRAVITINO_CLASSPATH} ${GRAVITINO_SERVER_NAME}

Review Comment:
   Where did you configure the iceberg rest server's classpath in script, I 
cannot find it.



-- 
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]

Reply via email to