MINOR: Make kafka-run-class.sh work under Cygwin

kafka-run-class.sh now runs under Cygwin; paths and classpath are set up properly.

**WARNING:**  The script was not tested on a Linux machine, only under Cygwin.  Prior to merge it into trunk, if accepted, please run a quick test to ensure nothing broke.  From my own code review, there should not be any problem, but we can never be too sure.

I do not have the environment to test it under Linux at this moment.

Author: deragon <32nx9812masakjds>

Reviewers: Ewen Cheslack-Postava <ewen@confluent.io>

Closes #1487 from deragon/trunk
This commit is contained in:
deragon 2016-08-09 08:33:53 -07:00 committed by Ewen Cheslack-Postava
parent fb65ff40a8
commit cb7af0b7fb
1 changed files with 19 additions and 4 deletions

View File

@ -20,6 +20,13 @@ then
exit 1 exit 1
fi fi
# CYGINW == 1 if Cygwin is detected, else 0.
if [[ $(uname -a) =~ "CYGWIN" ]]; then
CYGWIN=1
else
CYGWIN=0
fi
if [ -z "$INCLUDE_TEST_JARS" ]; then if [ -z "$INCLUDE_TEST_JARS" ]; then
INCLUDE_TEST_JARS=false INCLUDE_TEST_JARS=false
fi fi
@ -41,11 +48,11 @@ should_include_file() {
base_dir=$(dirname $0)/.. base_dir=$(dirname $0)/..
if [ -z "$SCALA_VERSION" ]; then if [ -z "$SCALA_VERSION" ]; then
SCALA_VERSION=2.10.6 SCALA_VERSION=2.10.6
fi fi
if [ -z "$SCALA_BINARY_VERSION" ]; then if [ -z "$SCALA_BINARY_VERSION" ]; then
SCALA_BINARY_VERSION=2.10 SCALA_BINARY_VERSION=2.10
fi fi
# run ./gradlew copyDependantLibs to get all dependant jars in a local dir # run ./gradlew copyDependantLibs to get all dependant jars in a local dir
@ -145,13 +152,16 @@ fi
# Log directory to use # Log directory to use
if [ "x$LOG_DIR" = "x" ]; then if [ "x$LOG_DIR" = "x" ]; then
LOG_DIR="$base_dir/logs" LOG_DIR="$base_dir/logs"
fi fi
# Log4j settings # Log4j settings
if [ -z "$KAFKA_LOG4J_OPTS" ]; then if [ -z "$KAFKA_LOG4J_OPTS" ]; then
# Log to console. This is a tool. # Log to console. This is a tool.
KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$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.
(( CYGWIN )) && LOG4J_DIR=$(cygpath --path --mixed "${LOG4J_DIR}")
KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:${LOG4J_DIR}"
else else
# create logs directory # create logs directory
if [ ! -d "$LOG_DIR" ]; then if [ ! -d "$LOG_DIR" ]; then
@ -159,6 +169,8 @@ else
fi fi
fi fi
# If Cygwin is detected, LOG_DIR is converted to Windows format.
(( CYGWIN )) && LOG_DIR=$(cygpath --path --mixed "${LOG_DIR}")
KAFKA_LOG4J_OPTS="-Dkafka.logs.dir=$LOG_DIR $KAFKA_LOG4J_OPTS" KAFKA_LOG4J_OPTS="-Dkafka.logs.dir=$LOG_DIR $KAFKA_LOG4J_OPTS"
# Generic jvm settings you want to add # Generic jvm settings you want to add
@ -236,6 +248,9 @@ if [ "x$GC_LOG_ENABLED" = "xtrue" ]; then
KAFKA_GC_LOG_OPTS="-Xloggc:$LOG_DIR/$GC_LOG_FILE_NAME -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps " KAFKA_GC_LOG_OPTS="-Xloggc:$LOG_DIR/$GC_LOG_FILE_NAME -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps "
fi fi
# If Cygwin is detected, classpath is converted to Windows format.
(( CYGWIN )) && 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_OPTS -cp $CLASSPATH $KAFKA_OPTS "$@" > "$CONSOLE_OUTPUT_FILE" 2>&1 < /dev/null &