Skip to content

Commit 73a96dc

Browse files
committed
Fix stop-edge.sh failing to stop its own process when IOTDB_HOME is set
start-edge.sh honours an IOTDB_HOME from the environment and passes that value to the JVM as -DIOTDB_HOME=..., while stop-edge.sh recomputed IOTDB_HOME from its own location and matched the command line against that string. When the two differ -- for example a versioned install reached through a symlink -- the stop declined to act on its own process, exited 0 and removed the PID file, so a service manager saw a successful stop while the process kept running. stop-edge.sh now honours IOTDB_HOME the same way start-edge.sh does, and falls back to comparing resolved paths when the literal match does not hit. The original literal comparison is tried first, so any command line that matched before still matches.
1 parent 1106d85 commit 73a96dc

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎scripts/sbin/stop-edge.sh‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@
2020

2121
# Stop IoTDB Edge (the merged ConfigNode + DataNode process).
2222

23-
IOTDB_HOME="$(cd "$(dirname "$0")"/.. && pwd)"
23+
if [ -z "${IOTDB_HOME}" ]; then
24+
IOTDB_HOME="$(cd "$(dirname "$0")"/.. && pwd)"
25+
fi
26+
27+
# Resolve symlinks and relative segments so that the same installation reached
28+
# through a different path still compares equal.
29+
resolve_home() {
30+
(cd "$1" 2>/dev/null && pwd -P) || printf '%s' "$1"
31+
}
32+
33+
IOTDB_HOME_RESOLVED="$(resolve_home "${IOTDB_HOME}")"
2434

2535
PID_FILE="${IOTDB_HOME}/edge.pid"
2636

@@ -31,9 +41,14 @@ is_same_edge_home() {
3141
return 0
3242
;;
3343
*)
34-
return 1
3544
;;
3645
esac
46+
# Fall back to comparing resolved paths, so that a start-edge.sh invoked with
47+
# IOTDB_HOME pointing at a symlink is still recognised here.
48+
local home="${command_line#*-DIOTDB_HOME=}"
49+
home="${home%% -D*}"
50+
[ -n "$home" ] && [ "$home" != "$command_line" ] || return 1
51+
[ "$(resolve_home "$home")" = "${IOTDB_HOME_RESOLVED}" ]
3752
}
3853

3954
is_edge_process() {

0 commit comments

Comments
 (0)