bitflicker64 commented on code in PR #3253:
URL: https://github.com/apache/hugegraph/pull/3253#discussion_r4556783407
##########
hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh:
##########
@@ -71,18 +109,46 @@ if [[ "$OPEN_SECURITY_CHECK" != "true" &&
"$OPEN_SECURITY_CHECK" != "false" ]];
exit_with_usage_help
fi
+# Verify the config files exist before reading them
+ensure_file_readable "$CONF/rest-server.properties" "REST server config" ||
exit 1
+ensure_file_readable "$CONF/gremlin-server.yaml" "Gremlin server config" ||
exit 1
Review Comment:
Important: `enable-auth.sh` writes `config: {tokens:
conf/rest-server.properties}` into `gremlin-server.yaml`, and
`HugeAuthenticator.setup` opens that relative path from `$TOP`, so under `-c`
Gremlin auth reads the packaged `rest-server.properties` and opens the auth
graph from `$TOP/conf/graphs` instead of the operator's backend. Check `tokens`
in `$CONF/gremlin-server.yaml` with `reject_relative_conf_path`, as for
`graphs`, and list it in `docs/server-runtime.md`.
##########
.github/workflows/pd-store-ci.yml:
##########
@@ -492,6 +492,8 @@ jobs:
"hugegraph-store/hg-store-node/target/surefire-reports/TEST-org.apache.hugegraph.store.business.StoredRowIngressTest.xml"
\
--require-test-report \
"hugegraph-store/hg-store-node/target/surefire-reports/TEST-org.apache.hugegraph.store.node.controller.ArthasSecurityTest.xml"
\
+ --require-test-report \
+
"hugegraph-store/hg-store-node/target/surefire-reports/TEST-org.apache.hugegraph.store.node.listener.PdConfigureListenerYamlTest.xml"
\
Review Comment:
Important: `test-check-jacoco-report.sh` asserts the exact set of
`--require-test-report` files for the `store` job, which still lists 8, so this
ninth entry fails its aggregation contract and the `Run JaCoCo report validator
tests` step of `pd_store / store` exits 1 at this head. Add
`TEST-org.apache.hugegraph.store.node.listener.PdConfigureListenerYamlTest.xml`
to that expected set.
##########
docs/server-runtime.md:
##########
@@ -54,6 +54,51 @@ bootstrap before Server accepts Gremlin requests. This does
not initialize the p
for every future Store target. Unit checks that obtain a stub verify lazy pool
construction; a successful RPC and its readback are separate runtime checks.
+### Launcher path overrides
+
+`bin/start-hugegraph.sh` accepts four path overrides. The override flags also
work in
+`bin/init-store.sh` (`-c`/`-o`), `bin/stop-hugegraph.sh` (`-i`) and the monitor
+cron job installed by `-m true`, so stop/restart/monitor stay consistent with
+the paths `bin/start-hugegraph.sh` used.
+
+| Flag | Meaning | Default (when omitted) |
+|---|---|---|
+| `-c <dir>` | Conf directory | `$TOP/conf` |
+| `-l <dir>` | Logs directory | `$TOP/logs` |
+| `-i <file>` | PID file | `$BIN/pid` |
+| `-o <dir>` | Plugins directory | `$TOP/plugins` |
+
+`$TOP` is the distribution's install root (the parent of `bin/`); `$BIN` is
+`$TOP/bin`.
+
+Relative values are resolved to absolute paths before use: `-l` and `-o` name
+directories the launcher writes into, so a relative or missing directory is
+created; `-c` is only ever read, so a relative value is resolved without
+creating anything, and a missing `-c` directory is a startup error. `-i`'s
+parent directory is created by `start-hugegraph.sh`,
+matching `-l`/`-o`; `stop-hugegraph.sh` and the monitor cron job resolve the
+same `-i` path read-only, without creating it, so a missing PID file or
+parent at stop time is a lookup error rather than being created.
+A value for `-c` must still be an existing path once resolved — the launcher
+does not create the external conf dir for you unless it already exists.
+
+Avoid `:`, `;`, `%`, and embedded CR/LF characters in any of these four paths:
+`-o` is joined into a `:`-separated CLASSPATH (and `;`-separated on Cygwin), so
+a `:`/`;` in that path corrupts the classpath; `%` is reserved by cron and is
+rejected whenever `-m true` persists these paths into a crontab line; CR/LF is
+always rejected. The launcher validates each path both before and after
+resolving a relative value to an absolute one, since resolution against the
+working directory can itself introduce a problem character that was not in
+the original value.
+
+When `-c` points at an external conf directory, keep `graphs` in
Review Comment:
Important: `CypherAPI` loads the fixed relative path
`conf/remote-objects.yaml` from `$TOP`, so under `-c` the Cypher client keeps
the packaged Gremlin host and port, and a second instance with its own Gremlin
port sends Cypher queries to the first instance. Load `remote-objects.yaml`
from the `-c` conf dir, as `PdConfigureListener` does for Store's
`application-pd.yml`.
##########
hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-monitor.sh:
##########
@@ -37,6 +37,42 @@ fi
# Monitor HugeGraphServer every minute, if the server crashes then restart it.
# Modify the frequency according to actual needs carefully.
-CRONTAB_JOB="*/1 * * * * export JAVA_HOME=$JAVA_HOME &&
$TOP/bin/monitor-hugegraph.sh"
-crontab_append "$CRONTAB_JOB"
+# Persist any path overrides (-c/-l/-i/-o) that the caller
(start-hugegraph.sh) exported.
+# Every value goes through cron_quote: it validates (CR/LF, '%') and emits ONE
complete
+# POSIX shell word.
+JAVA_HOME_Q="$(cron_quote "$JAVA_HOME" "JAVA_HOME")" || exit 1
+MONITOR_RAW="$TOP/bin/monitor-hugegraph.sh"
+MONITOR_Q="$(cron_quote "$MONITOR_RAW" "monitor script path")" || exit 1
+
+CRONTAB_JOB="*/1 * * * * export JAVA_HOME=$JAVA_HOME_Q &&"
+if [ -n "$CONF_OVERRIDE" ]; then
+ CONF_Q="$(cron_quote "$CONF_OVERRIDE" "CONF_OVERRIDE")" || exit 1
+ CRONTAB_JOB="$CRONTAB_JOB export CONF_OVERRIDE=$CONF_Q &&"
+fi
+if [ -n "$LOGS_OVERRIDE" ]; then
+ LOGS_Q="$(cron_quote "$LOGS_OVERRIDE" "LOGS_OVERRIDE")" || exit 1
+ CRONTAB_JOB="$CRONTAB_JOB export LOGS_OVERRIDE=$LOGS_Q &&"
+fi
+if [ -n "$PID_FILE_OVERRIDE" ]; then
+ PID_Q="$(cron_quote "$PID_FILE_OVERRIDE" "PID_FILE_OVERRIDE")" || exit 1
+ CRONTAB_JOB="$CRONTAB_JOB export PID_FILE_OVERRIDE=$PID_Q &&"
+fi
+if [ -n "$PLUGINS_OVERRIDE" ]; then
+ PLUGINS_Q="$(cron_quote "$PLUGINS_OVERRIDE" "PLUGINS_OVERRIDE")" || exit 1
+ CRONTAB_JOB="$CRONTAB_JOB export PLUGINS_OVERRIDE=$PLUGINS_Q &&"
+fi
+CRONTAB_JOB="$CRONTAB_JOB $MONITOR_Q"
+
+# Keys cover both the current quoted form and the legacy unquoted form (older
+# start-monitor.sh versions wrote "... && $TOP/bin/monitor-hugegraph.sh"
+# without quoting), so an in-place upgrade detects an existing job as a
+# duplicate instead of installing a second one alongside it.
+# The legacy key is anchored with the literal "&& " prefix (not just the bare
+# path): grep -F does substring matching, so an unanchored bare path would
+# also match as a SUBSTRING of a different install's longer path (e.g. the
+# key for /opt/hg matches a crontab line for /data/opt/hg), causing a
+# false-positive "already installed" here and a wrong-job removal in
+# stop-monitor.sh.
+MONITOR_LEGACY_KEY="&& $MONITOR_RAW"
+crontab_append "$CRONTAB_JOB" "$MONITOR_Q" "$MONITOR_LEGACY_KEY"
Review Comment:
Important: both keys depend only on `$TOP`, so for two instances of one
install with different `-c`/`-i`, the second `-m true` finds the first job and
installs nothing, and `stop-hugegraph.sh -i <second pid>` removes the first
instance's job. Include the PID file in the key here and in `stop-monitor.sh`,
so each `-i` gets its own job.
--
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]