bitflicker64 commented on code in PR #3253:
URL: https://github.com/apache/hugegraph/pull/3253#discussion_r4642759493


##########
hugegraph-server/hugegraph-dist/src/assembly/static/bin/stop-monitor.sh:
##########
@@ -25,11 +25,39 @@ function abs_path() {
     echo "$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 }
 
-BIN=`abs_path`
-TOP="$(cd $BIN/../ && pwd)"
+BIN="$(abs_path)"
+TOP="$(cd "$BIN"/../ && pwd)"
 
-. $BIN/util.sh
+. "$BIN"/util.sh
 
-CRONTAB_JOB="$TOP/bin/monitor-hugegraph.sh"
+# Must match the serialized form start-monitor.sh saves (one quoted shell 
word).
+# shell_quote (not cron_quote) so removal is not blocked by validation.
+MONITOR_RAW="$TOP/bin/monitor-hugegraph.sh"
+MONITOR_Q="$(shell_quote "$MONITOR_RAW")"
 
-crontab_remove "$CRONTAB_JOB"
+# Match both the current quoted form and the legacy unquoted form (older
+# start-monitor.sh versions wrote "... && $TOP/bin/monitor-hugegraph.sh"
+# without quoting). Otherwise a job installed before this quoting fix survives
+# an in-place upgrade: grep -F never matches it, removal silently no-ops, and
+# the stale cron entry can restart the server within a minute.
+# 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), removing the
+# wrong install's job.
+MONITOR_KEY="$MONITOR_Q"

Review Comment:
   Important: the default key `'$TOP/bin/monitor-hugegraph.sh'` is a substring 
of every `-i` job line, so `stop-hugegraph.sh` without `-i` also removes the 
monitor jobs of instances started with `-i`, and `start-monitor.sh` without 
`-i` finds their job and installs none. Mark the default job and key too, for 
example `# pidfile:default`, in both `start-monitor.sh` and this script, so no 
key is a prefix of another.



##########
hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh:
##########
@@ -71,18 +109,69 @@ 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
+
 GREMLIN_SERVER_URL=$(read_property "$CONF/rest-server.properties" 
"gremlinserver.url")
 if [ -z "$GREMLIN_SERVER_URL" ]; then
     GREMLIN_SERVER_URL="http://127.0.0.1:8182";
 fi
 REST_SERVER_URL=$(read_property "$CONF/rest-server.properties" 
"restserver.url")
 
+# 'graphs' is read by HugeGraphServer/GraphManager relative to the working
+# directory (set to $TOP below), not relative to $CONF.
+GRAPHS_DIR=$(read_property "$CONF/rest-server.properties" "graphs")
+reject_relative_conf_path "$GRAPHS_DIR" "graphs" 
"$CONF/rest-server.properties" || exit 1
+
+# enable-auth.sh writes 'config: {tokens: conf/rest-server.properties}' into
+# gremlin-server.yaml. Like 'graphs' above, HugeAuthenticator.setup opens that
+# path relative to the working directory ($TOP below), not relative to
+# $CONF, so under -c a relative value silently keeps reading the packaged
+# rest-server.properties (and the auth graph(s) it points at).
+#
+# We parse the single-line inline-flow form ('config: {...}' closed on
+# the same line) that enable-auth.sh writes. A multi-line/block-style YAML
+# 'config:' mapping (or an inline '{' left open across lines) is NOT parsed.
+CONFIG_LINE=$(grep -E '^[[:blank:]]*config:' "$CONF/gremlin-server.yaml" | 
tail -1)
+if [ -n "$CONFIG_LINE" ] && \
+   ! echo "$CONFIG_LINE" | grep -qE 
'^[[:blank:]]*config:[[:blank:]]*\{[^{}]*\}[[:blank:]]*$'; then

Review Comment:
   Critical: the stock `conf/gremlin-server.yaml` ends with multi-line 
serializer `config: {` entries, so this check rejects the shipped config and 
every start without `enable-auth.sh` exits 1 before launching the server; all 
six failing CI jobs at this head stop on this error. Match only a `config:` 
line that contains `tokens:`, and add a fixture that starts from the stock 
`gremlin-server.yaml`.



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

Reply via email to