From 4ad54181b4b990c3f10f75b18b050c1951cbd3e1 Mon Sep 17 00:00:00 2001 From: Dandelion <49650772+aroundabout@users.noreply.github.com> Date: Fri, 8 Sep 2023 22:07:57 +0800 Subject: [PATCH] fix(dist): avoid var PRELOAD cover environmnet vars (#2302) Update hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh --------- Co-authored-by: imbajin --- .../assembly/static/bin/start-hugegraph.sh | 58 ++++++++----------- .../src/assembly/static/bin/util.sh | 5 ++ 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh index c53df91b9..9ad7da8fa 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh @@ -18,43 +18,11 @@ OPEN_MONITOR="false" OPEN_SECURITY_CHECK="true" DAEMON="true" -PRELOAD="false" #VERBOSE="" GC_OPTION="" USER_OPTION="" SERVER_STARTUP_TIMEOUT_S=30 - -while getopts "d:g:m:p:s:j:t:v" arg; do - case ${arg} in - d) DAEMON="$OPTARG" ;; - g) GC_OPTION="$OPTARG" ;; - m) OPEN_MONITOR="$OPTARG" ;; - p) PRELOAD="$OPTARG" ;; - s) OPEN_SECURITY_CHECK="$OPTARG" ;; - j) USER_OPTION="$OPTARG" ;; - t) SERVER_STARTUP_TIMEOUT_S="$OPTARG" ;; - # TODO: should remove it in future (check the usage carefully) - v) VERBOSE="verbose" ;; - ?) echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-p true|false] [-s true|false] [-j java_options] - [-t timeout]" && exit 1 ;; - esac -done - -if [[ "$OPEN_MONITOR" != "true" && "$OPEN_MONITOR" != "false" ]]; then - echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-p true|false] [-s true|false] [-j java_options]" - exit 1 -fi - -if [[ "$OPEN_SECURITY_CHECK" != "true" && "$OPEN_SECURITY_CHECK" != "false" ]]; then - echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-p true|false] [-s true|false] [-j java_options]" - exit 1 -fi - -if [[ "$PRELOAD" != "true" && "$PRELOAD" != "false" ]]; then - echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-p true|false] [-s true|false] [-j java_options]" - exit 1 -fi - +# todo: move abs_path funtion to shell like util.sh function abs_path() { SOURCE="${BASH_SOURCE[0]}" while [[ -h "$SOURCE" ]]; do @@ -74,6 +42,30 @@ PID_FILE="$BIN/pid" . "$BIN"/util.sh +while getopts "d:g:m:p:s:j:t:v" arg; do + case ${arg} in + d) DAEMON="$OPTARG" ;; + g) GC_OPTION="$OPTARG" ;; + m) OPEN_MONITOR="$OPTARG" ;; + p) PRELOAD="$OPTARG" ;; + s) OPEN_SECURITY_CHECK="$OPTARG" ;; + j) USER_OPTION="$OPTARG" ;; + t) SERVER_STARTUP_TIMEOUT_S="$OPTARG" ;; + # TODO: should remove it in future (check the usage carefully) + v) VERBOSE="verbose" ;; + # Note: update usage info when the params changed + ?) exit_with_usage_help ;; + esac +done + +if [[ "$OPEN_MONITOR" != "true" && "$OPEN_MONITOR" != "false" ]]; then + exit_with_usage_help +fi + +if [[ "$OPEN_SECURITY_CHECK" != "true" && "$OPEN_SECURITY_CHECK" != "false" ]]; then + exit_with_usage_help +fi + 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" diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh index d03083388..64980403b 100755 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh @@ -368,3 +368,8 @@ function kill_process_and_wait() { kill_process "$process_name" "$pid" wait_for_shutdown "$process_name" "$pid" "$timeout_s" } + +function exit_with_usage_help(){ + echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-p true|false] [-s true|false] [-j java_options] [-t timeout]" + exit 1 +}