Browse Source

KAFKA-15685: Add support for MinGW and MSYS2 (windows OS) (#13321)

Kafka class runner does not work with MINGW/Git Bash on Windows. This commit adds support for MinGW and MSYS2 development environments.

Reviewers: Divij Vaidya <diviv@amazon.com>
pull/14481/merge
maniekes 1 year ago committed by GitHub
parent
commit
987609404c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      bin/kafka-run-class.sh

21
bin/kafka-run-class.sh

@ -20,11 +20,12 @@ then
exit 1 exit 1
fi fi
# CYGWIN == 1 if Cygwin is detected, else 0. # WINDOWS_OS_FORMAT == 1 if Cygwin or MinGW is detected, else 0.
if [[ $(uname -a) =~ "CYGWIN" ]]; then if [[ $(uname -a) =~ "CYGWIN" || $(uname -a) =~ "MINGW" || $(uname -a) =~ "MSYS" ]]; then
CYGWIN=1 WINDOWS_OS_FORMAT=1
export MSYS2_ARG_CONV_EXCL="-Xlog:gc*:file=;-Dlog4j.configuration=;$MSYS2_ARG_CONV_EXCL"
else else
CYGWIN=0 WINDOWS_OS_FORMAT=0
fi fi
if [ -z "$INCLUDE_TEST_JARS" ]; then if [ -z "$INCLUDE_TEST_JARS" ]; then
@ -229,7 +230,7 @@ if [ -z "$KAFKA_LOG4J_OPTS" ]; then
# Log to console. This is a tool. # Log to console. This is a tool.
LOG4J_DIR="$base_dir/config/tools-log4j.properties" LOG4J_DIR="$base_dir/config/tools-log4j.properties"
# If Cygwin is detected, LOG4J_DIR is converted to Windows format. # If Cygwin is detected, LOG4J_DIR is converted to Windows format.
(( CYGWIN )) && LOG4J_DIR=$(cygpath --path --mixed "${LOG4J_DIR}") (( WINDOWS_OS_FORMAT )) && LOG4J_DIR=$(cygpath --path --mixed "${LOG4J_DIR}")
KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:${LOG4J_DIR}" KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:${LOG4J_DIR}"
else else
# create logs directory # create logs directory
@ -239,8 +240,8 @@ else
fi fi
# If Cygwin is detected, LOG_DIR is converted to Windows format. # If Cygwin is detected, LOG_DIR is converted to Windows format.
(( CYGWIN )) && LOG_DIR=$(cygpath --path --mixed "${LOG_DIR}") (( WINDOWS_OS_FORMAT )) && LOG_DIR=$(cygpath --path --mixed "${LOG_DIR}")
KAFKA_LOG4J_OPTS="-Dkafka.logs.dir=$LOG_DIR $KAFKA_LOG4J_OPTS" KAFKA_LOG4J_CMD_OPTS="-Dkafka.logs.dir=$LOG_DIR $KAFKA_LOG4J_OPTS"
# Generic jvm settings you want to add # Generic jvm settings you want to add
if [ -z "$KAFKA_OPTS" ]; then if [ -z "$KAFKA_OPTS" ]; then
@ -337,11 +338,11 @@ fi
CLASSPATH=${CLASSPATH#:} CLASSPATH=${CLASSPATH#:}
# If Cygwin is detected, classpath is converted to Windows format. # If Cygwin is detected, classpath is converted to Windows format.
(( CYGWIN )) && CLASSPATH=$(cygpath --path --mixed "${CLASSPATH}") (( WINDOWS_OS_FORMAT )) && CLASSPATH=$(cygpath --path --mixed "${CLASSPATH}")
# Launch mode # Launch mode
if [ "x$DAEMON_MODE" = "xtrue" ]; then if [ "x$DAEMON_MODE" = "xtrue" ]; then
nohup "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_OPTS -cp "$CLASSPATH" $KAFKA_OPTS "$@" > "$CONSOLE_OUTPUT_FILE" 2>&1 < /dev/null & nohup "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_CMD_OPTS -cp "$CLASSPATH" $KAFKA_OPTS "$@" > "$CONSOLE_OUTPUT_FILE" 2>&1 < /dev/null &
else else
exec "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_OPTS -cp "$CLASSPATH" $KAFKA_OPTS "$@" exec "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_CMD_OPTS -cp "$CLASSPATH" $KAFKA_OPTS "$@"
fi fi

Loading…
Cancel
Save