File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed
Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -31,11 +31,11 @@ if ($env:JAVA_HOME -and (Test-Path (Join-Path $env:JAVA_HOME "bin\java.exe"))) {
3131 $Java = " java"
3232}
3333
34- # Get Java major version
34+ # Get Java major version (handles both Java 8 "1.8.x" and Java 9+ "11.x" formats)
3535try {
3636 $versionOutput = & $Java - version 2>&1 | Select-Object - First 1
37- if ($versionOutput -match ' version "(\d+)' ) {
38- $JavaVersion = [int ]$Matches [1 ]
37+ if ($versionOutput -match ' version "(1\.)?( \d+)' ) {
38+ $JavaVersion = [int ]$Matches [2 ]
3939 } else {
4040 Write-Error " Failed to detect Java version"
4141 exit 1
Original file line number Diff line number Diff line change 3232 JAVA=" java"
3333fi
3434
35- # Get Java major version
36- JAVA_VERSION=$( $JAVA -version 2>&1 | head -1 | sed -E ' s/.*version "([0-9]+).*/\1 /' )
35+ # Get Java major version (handles both Java 8 "1.8.x" and Java 9+ "11.x" formats)
36+ JAVA_VERSION=$( $JAVA -version 2>&1 | head -1 | sed -E ' s/.*version "(1\.)?( [0-9]+).*/\2 /' )
3737if [ -z " $JAVA_VERSION " ] || ! [ " $JAVA_VERSION " -gt 0 ] 2> /dev/null; then
3838 echo " Failed to detect Java version" >&2
3939 exit 1
@@ -116,11 +116,15 @@ if ! kill -0 "$NEW_PID" 2>/dev/null; then
116116fi
117117
118118# Verify it's the expected Java process
119- if ! ps -p " $NEW_PID " -o args= 2> /dev/null | grep -q " dongting.dist/com.github.dtprj.dongting.dist.Bootstrap" ; then
120- echo " Failed to start dongting: PID $NEW_PID is not a dongting process" >&2
121- kill " $NEW_PID " 2> /dev/null || true
122- exit 1
123- fi
119+ CMDLINE=$( ps -p " $NEW_PID " -o args= 2> /dev/null) || CMDLINE=" "
120+ case " $CMDLINE " in
121+ * " dongting.dist/com.github.dtprj.dongting.dist.Bootstrap" * ) ;;
122+ * )
123+ echo " Failed to start dongting: PID $NEW_PID is not a dongting process" >&2
124+ kill " $NEW_PID " 2> /dev/null || true
125+ exit 1
126+ ;;
127+ esac
124128
125129echo " $NEW_PID " > " $PID_FILE " || {
126130 echo " Failed to write PID file $PID_FILE " >&2
You can’t perform that action at this time.
0 commit comments