imbajin commented on code in PR #2952:
URL:
https://github.com/apache/incubator-hugegraph/pull/2952#discussion_r2837674193
##########
hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh:
##########
@@ -15,8 +15,71 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+set -euo pipefail
-# start hugegraph pd
-./bin/start-hugegraph-pd.sh -j "$JAVA_OPTS"
+log() { echo "[hugegraph-pd-entrypoint] $*"; }
+fail_on_deprecated() {
+ local old_name="$1" new_name="$2"
+ if [[ -n "${!old_name:-}" ]]; then
+ echo "ERROR: deprecated env '${old_name}' detected. Use '${new_name}'
instead." >&2
+ exit 2
+ fi
+}
+
+require_env() {
+ local name="$1"
+ if [[ -z "${!name:-}" ]]; then
+ echo "ERROR: missing required env '${name}'" >&2; exit 2
+ fi
+}
+
+json_escape() {
+ local s="$1"
+ s=${s//\\/\\\\}; s=${s//\"/\\\"}; s=${s//$'\n'/}
+ printf "%s" "$s"
+}
+
+# ── Guard deprecated vars ─────────────────────────────────────────────
+fail_on_deprecated "GRPC_HOST" "HG_PD_GRPC_HOST"
+fail_on_deprecated "RAFT_ADDRESS" "HG_PD_RAFT_ADDRESS"
+fail_on_deprecated "RAFT_PEERS" "HG_PD_RAFT_PEERS_LIST"
+fail_on_deprecated "PD_INITIAL_STORE_LIST" "HG_PD_INITIAL_STORE_LIST"
+
+# ── Required vars ─────────────────────────────────────────────────────
+require_env "HG_PD_GRPC_HOST"
+require_env "HG_PD_RAFT_ADDRESS"
+require_env "HG_PD_RAFT_PEERS_LIST"
+require_env "HG_PD_INITIAL_STORE_LIST"
+
+# ── Defaults ──────────────────────────────────────────────────────────
+: "${HG_PD_GRPC_PORT:=8686}"
+: "${HG_PD_REST_PORT:=8620}"
+: "${HG_PD_DATA_PATH:=/hugegraph-pd/pd_data}"
+
+# ── Build SPRING_APPLICATION_JSON ─────────────────────────────────────
+SPRING_APPLICATION_JSON="$(cat <<JSON
+{
+ "grpc": { "host": "$(json_escape "${HG_PD_GRPC_HOST}")",
+ "port": "$(json_escape "${HG_PD_GRPC_PORT}")" },
+ "server": { "port": "$(json_escape "${HG_PD_REST_PORT}")" },
+ "raft": { "address": "$(json_escape "${HG_PD_RAFT_ADDRESS}")",
+ "peers-list": "$(json_escape "${HG_PD_RAFT_PEERS_LIST}")" },
+ "pd": { "data-path": "$(json_escape "${HG_PD_DATA_PATH}")",
+ "initial-store-list": "$(json_escape
"${HG_PD_INITIAL_STORE_LIST}")" }
Review Comment:
⚠️ **`HG_PD_INITIAL_STORE_COUNT` is not currently mapped into
`SPRING_APPLICATION_JSON` — recommend explicit wiring**
At the moment, `HG_PD_INITIAL_STORE_COUNT` is not included in the generated
`SPRING_APPLICATION_JSON`. This may still work in current packaging because
`conf/application.yml` already sets `pd.initial-store-count: 1` for
single-node, and JSON only overrides selected keys.
However, explicitly wiring this value is safer and clearer:
1. Avoids hidden dependency on base file defaults.
2. Keeps behavior stable if packaged defaults change later.
3. Exposes a useful tuning knob for multi-node bootstrap scenarios.
```suggestion
: "${HG_PD_INITIAL_STORE_COUNT:=1}"
SPRING_APPLICATION_JSON="$(cat <<JSON
{
"grpc": { "host": "$(json_escape "${HG_PD_GRPC_HOST}")",
"port": "$(json_escape "${HG_PD_GRPC_PORT}")" },
"server": { "port": "$(json_escape "${HG_PD_REST_PORT}")" },
"raft": { "address": "$(json_escape "${HG_PD_RAFT_ADDRESS}")",
"peers-list": "$(json_escape "${HG_PD_RAFT_PEERS_LIST}")" },
"pd": { "data-path": "$(json_escape "${HG_PD_DATA_PATH}")",
"initial-store-list": "$(json_escape
"${HG_PD_INITIAL_STORE_LIST}")",
"initial-store-count": ${HG_PD_INITIAL_STORE_COUNT} }
}
JSON
)"
```
`initial-store-count` should remain a numeric JSON value (unquoted).
--
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]