Skip to content

Commit

Permalink
Update the start scripts so that the ksql server always generates a g…
Browse files Browse the repository at this point in the history
…c log (#674)
  • Loading branch information
apurvam authored Jan 31, 2018
1 parent 43e75ce commit 0fd4806
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 10 deletions.
42 changes: 35 additions & 7 deletions bin/ksql-run-class
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,56 @@ then
usage
fi

MAIN="$1"
shift

DAEMON_NAME=""
GC_LOG_ENABLED=""
DAEMON_MODE=""
HELP=""

while [ $# -gt 0 ]; do
COMMAND="$1"
case "$COMMAND" in
-help)
HELP="true"
-name)
DAEMON_NAME=$2
shift 2
;;
-loggc)
GC_LOG_ENABLED="true"
shift
;;
-daemon)
DAEMON_MODE="true"
shift
;;
*)
-help)
HELP="true"
shift
;;
*)
break
;;
esac
done

MAIN="$1"
shift


# GC options
GC_FILE_SUFFIX='-gc.log'
GC_LOG_FILE_NAME=''
KSQL_GC_LOG_OPTS=""
if [ "x$GC_LOG_ENABLED" = "xtrue" ]; then
GC_LOG_FILE_NAME=$DAEMON_NAME$GC_FILE_SUFFIX
# the first segment of the version number, which is '1' for releases before Java 9
# it then becomes '9', '10', ...
JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*"/\1/p')
if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then
KSQL_GC_LOG_OPTS="-Xlog:gc*:file=$LOG_DIR/$GC_LOG_FILE_NAME:time,tags:filecount=10,filesize=102400"
else
KSQL_GC_LOG_OPTS="-Xloggc:$LOG_DIR/$GC_LOG_FILE_NAME -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
fi
fi


if [ "x$HELP" = "xtrue" ]; then
usage
fi
Expand All @@ -133,6 +160,7 @@ OPTIONS+=($KSQL_JVM_PERFORMANCE_OPTS)
OPTIONS+=($KSQL_JMX_OPTS)
OPTIONS+=($KSQL_LOG4J_OPTS)
OPTIONS+=($KSQL_OPTS)
OPTIONS+=($KSQL_GC_LOG_OPTS)

# Launch mode
if [ "x$DAEMON_MODE" = "xtrue" ]; then
Expand Down
20 changes: 19 additions & 1 deletion bin/ksql-server-start
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#
set -ue

if [ $# -lt 1 ];
then
echo "$USAGE: $0 [-daemon] ksqlserver.properties"
exit 1
fi

base_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )
: "${KSQL_CONFIG_DIR:="$base_dir/config"}"

Expand All @@ -14,7 +20,19 @@ if [ -z "$KSQL_LOG4J_OPTS" ] && [ -e "$KSQL_CONFIG_DIR/log4j-silent.properties"
export KSQL_LOG4J_OPTS="-Dlog4j.configuration=file:$KSQL_CONFIG_DIR/log4j-rolling.properties"
fi

EXTRA_ARGS="-name ksql-server -loggc"

COMMAND=$1
case $COMMAND in
-daemon)
EXTRA_ARGS="-daemon "$EXTRA_ARGS
shift
;;
*)
;;
esac

# TODO: Enable specification of properties via command-line arg in the KsqlRestApplication class
# so that useful defaults for bootstrap server, port, etc. can be established here

exec "$base_dir"/bin/ksql-run-class io.confluent.ksql.rest.server.KsqlRestApplication "$@"
exec "$base_dir"/bin/ksql-run-class $EXTRA_ARGS io.confluent.ksql.rest.server.KsqlRestApplication "$@"
4 changes: 2 additions & 2 deletions config/log4j-file.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ log4j.rootLogger=WARN, default.file
log4j.appender.default.file=io.confluent.ksql.util.TimestampLogFileAppender
log4j.appender.default.file.ImmediateFlush=true
log4j.appender.default.file.append=false
log4j.appender.default.file.file=${ksql.log.dir}/ksql-logs/cli-%timestamp.log
log4j.appender.default.file.file=${ksql.log.dir}/cli-%timestamp.log
log4j.appender.default.file.layout=org.apache.log4j.PatternLayout
log4j.appender.default.file.layout.ConversionPattern=[%d] %p %m (%c:%L)%n
log4j.appender.default.file.layout.ConversionPattern=[%d] %p %m (%c:%L)%n

0 comments on commit 0fd4806

Please sign in to comment.