From daa6ebb04a6e5275d237f95c0264b1a57069a797 Mon Sep 17 00:00:00 2001 From: Himanshu Verma Date: Fri, 5 Jun 2026 16:18:54 +0530 Subject: [PATCH 1/2] fix(docker): supervise Java process in entrypoints instead of tail -f /dev/null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: all three docker-entrypoint.sh files used tail -f /dev/null to keep the container alive. When Java crashed, tail kept running and the container stayed up with no Java inside — Docker restart policy never fired. PD and Store fix: replace daemon start + tail -f /dev/null with -d false, which triggers the foreground branch added in chunks 2-3. exec java replaces the shell with Java directly, so the entrypoint blocks and exits with Java's real exit code when Java exits. Server fix: keep daemon start (wait-partition.sh must run after Java is up). Replace tail -f /dev/null with tail --pid=$(cat ./bin/pid) -f /dev/null. When Java exits, tail --pid returns, entrypoint exits 1, restart policy fires. Note: server entrypoint always exits 1 (cannot get Java's real exit code since start-hugegraph.sh calls disown before returning). This is sufficient for --restart=on-failure. Verified locally: kill -9 Java inside running container -> container exits -> Docker restarts it automatically (tested 3 times for server, PD restart loop confirmed for pd). Related to: #3043 --- hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh | 3 +-- hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh | 6 +++++- hugegraph-store/hg-store-dist/docker/docker-entrypoint.sh | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh b/hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh index d1ae5c3c3a..529936d06a 100755 --- a/hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh +++ b/hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh @@ -82,5 +82,4 @@ log " pd.initial-store-list=${HG_PD_INITIAL_STORE_LIST}" log " pd.initial-store-count=${HG_PD_INITIAL_STORE_COUNT}" log " pd.data-path=${HG_PD_DATA_PATH}" -./bin/start-hugegraph-pd.sh -j "${JAVA_OPTS:-}" -tail -f /dev/null +./bin/start-hugegraph-pd.sh -d false -j "${JAVA_OPTS:-}" diff --git a/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh b/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh index 779c3eb704..d8090ba54c 100755 --- a/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh +++ b/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh @@ -91,4 +91,8 @@ if [[ "${ACTUAL_BACKEND}" == "hstore" ]]; then ./bin/wait-partition.sh || log "WARN: partitions not assigned yet" fi -tail -f /dev/null +PID=$(cat ./bin/pid 2>/dev/null || true) +if [[ -n "$PID" ]]; then + tail --pid="$PID" -f /dev/null + exit 1 +fi diff --git a/hugegraph-store/hg-store-dist/docker/docker-entrypoint.sh b/hugegraph-store/hg-store-dist/docker/docker-entrypoint.sh index 1bdaaafc5a..8ea9022a33 100755 --- a/hugegraph-store/hg-store-dist/docker/docker-entrypoint.sh +++ b/hugegraph-store/hg-store-dist/docker/docker-entrypoint.sh @@ -77,5 +77,4 @@ log " raft.address=${HG_STORE_RAFT_ADDRESS}" log " server.port=${HG_STORE_REST_PORT}" log " app.data-path=${HG_STORE_DATA_PATH}" -./bin/start-hugegraph-store.sh -j "${JAVA_OPTS:-}" -tail -f /dev/null +./bin/start-hugegraph-store.sh -d false -j "${JAVA_OPTS:-}" From f20b8a495270700c68b7732de375265bdc089b16 Mon Sep 17 00:00:00 2001 From: Himanshu Verma Date: Sun, 7 Jun 2026 11:22:36 +0530 Subject: [PATCH 2/2] fix(docker): forward SIGTERM to Java on docker stop in server entrypoint tail --pid does not forward signals to the supervised process. Add a TERM/INT trap that sends SIGTERM to Java and polls with kill -0 until Java exits cleanly before the entrypoint exits. Addresses review feedback from imbajin on #3049. --- hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh b/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh index d8090ba54c..2c76a54435 100755 --- a/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh +++ b/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh @@ -93,6 +93,7 @@ fi PID=$(cat ./bin/pid 2>/dev/null || true) if [[ -n "$PID" ]]; then + trap 'kill -TERM "$PID" 2>/dev/null; while kill -0 "$PID" 2>/dev/null; do sleep 1; done; exit 0' TERM INT tail --pid="$PID" -f /dev/null exit 1 fi