Skip to content

Commit 817887d

Browse files
authored
fix(docker): supervise Java process in entrypoints instead of tail -f /dev/null (#3051)
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. 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).
1 parent 1f61c48 commit 817887d

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,4 @@ log " pd.initial-store-list=${HG_PD_INITIAL_STORE_LIST}"
8282
log " pd.initial-store-count=${HG_PD_INITIAL_STORE_COUNT}"
8383
log " pd.data-path=${HG_PD_DATA_PATH}"
8484

85-
./bin/start-hugegraph-pd.sh -j "${JAVA_OPTS:-}"
86-
tail -f /dev/null
85+
./bin/start-hugegraph-pd.sh -d false -j "${JAVA_OPTS:-}"

hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,9 @@ if [[ "${ACTUAL_BACKEND}" == "hstore" ]]; then
9191
./bin/wait-partition.sh || log "WARN: partitions not assigned yet"
9292
fi
9393

94-
tail -f /dev/null
94+
PID=$(cat ./bin/pid 2>/dev/null || true)
95+
if [[ -n "$PID" ]]; then
96+
trap 'kill -TERM "$PID" 2>/dev/null; while kill -0 "$PID" 2>/dev/null; do sleep 1; done; exit 0' TERM INT
97+
tail --pid="$PID" -f /dev/null
98+
exit 1
99+
fi

hugegraph-store/hg-store-dist/docker/docker-entrypoint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,4 @@ log " raft.address=${HG_STORE_RAFT_ADDRESS}"
7777
log " server.port=${HG_STORE_REST_PORT}"
7878
log " app.data-path=${HG_STORE_DATA_PATH}"
7979

80-
./bin/start-hugegraph-store.sh -j "${JAVA_OPTS:-}"
81-
tail -f /dev/null
80+
./bin/start-hugegraph-store.sh -d false -j "${JAVA_OPTS:-}"

0 commit comments

Comments
 (0)