Copilot commented on code in PR #11272:
URL: https://github.com/apache/gravitino/pull/11272#discussion_r3315750811


##########
dev/docker/gravitino/docker-entrypoint.sh:
##########
@@ -0,0 +1,70 @@
+#!/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.
+#
+# Docker container entrypoint for the Gravitino server image.
+# This script performs container-specific initialization before starting the 
server:
+#   1. Rewrites gravitino.conf from environment variables (skipped if 
SKIP_CONFIG_REWRITE=true).
+#   2. Creates symlinks for optional JDBC drivers placed in 
/opt/gravitino/jdbc-drivers/.
+#   3. Creates symlinks for optional Iceberg bundle jars placed in 
/opt/gravitino/iceberg-bundles/.
+#   4. Starts the Gravitino server in the foreground (replacing this shell 
process).
+#
+# This script is NOT intended to be called directly. It is set as the Docker 
ENTRYPOINT and
+# is invoked automatically when the container starts.
+# For non-Docker deployments, use bin/gravitino.sh {start|stop|restart|status} 
instead.
+
+set -ex
+bin_dir="$(dirname "${BASH_SOURCE-$0}")"
+gravitino_dir="$(cd "${bin_dir}/../" > /dev/null; pwd)"
+
+cd "${gravitino_dir}"
+
+# Skip config rewrite if SKIP_CONFIG_REWRITE is set (e.g., in Kubernetes where 
config
+# is mounted via ConfigMap and should not be overwritten by environment 
variables).
+if [ "${SKIP_CONFIG_REWRITE}" != "true" ]; then
+  python docker/rewrite_gravitino_server_config.py
+fi
+
+# Create soft links for JDBC drivers
+jdbc_driver_dir="${gravitino_dir}/jdbc-drivers"
+
+if [ -d "${jdbc_driver_dir}" ]; then
+  mkdir -p "${gravitino_dir}/libs"
+  find "${jdbc_driver_dir}" -name "mysql-connector-java-*.jar" -exec ln -sfv 
{} "${gravitino_dir}/libs/" \;
+  find "${jdbc_driver_dir}" -name "postgresql-*.jar" -exec ln -sfv {} 
"${gravitino_dir}/libs/" \;
+fi
+
+# Create soft links for Iceberg bundle jars
+iceberg_bundle_dir="${gravitino_dir}/iceberg-bundles"
+lakehouse_iceberg_lib_dir="${gravitino_dir}/catalogs/lakehouse-iceberg/libs"
+iceberg_rest_lib_dir="${gravitino_dir}/iceberg-rest-server/libs"
+
+if [ -d "${iceberg_bundle_dir}" ]; then
+  mkdir -p "${lakehouse_iceberg_lib_dir}"
+  mkdir -p "${iceberg_rest_lib_dir}"
+  find "${iceberg_bundle_dir}" -name '*.jar' \
+    -exec ln -sfv {} "${lakehouse_iceberg_lib_dir}" \; \
+    -exec ln -sfv {} "${iceberg_rest_lib_dir}" \;
+fi
+
+JAVA_OPTS+=" -XX:-UseContainerSupport"
+export JAVA_OPTS
+
+# Run the server in the foreground so this process (PID 1) is the JVM.
+# This ensures SIGTERM is forwarded correctly for graceful shutdown.
+exec ./bin/gravitino.sh run

Review Comment:
   This still leaves `bin/gravitino.sh`'s Bash process as PID 1, because 
`run()` starts the JVM without `exec` (see 
`bin/gravitino.sh.template:128-130`). Docker will send SIGTERM to that shell, 
not directly to the JVM, so the stated graceful-shutdown improvement is not 
achieved. Consider making the `run` path exec the Java command or otherwise 
forwarding signals to the child process.
   



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