Created
February 21, 2018 18:08
-
-
Save praveenkannan/6cff5cde0ff6590819481083261f8a62 to your computer and use it in GitHub Desktop.
Modified kafka-rest-run-class for enabling debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Copyright 2014 Confluent Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
base_dir=$(dirname $0)/.. | |
# Development jars. `mvn package` should collect all the required dependency jars here | |
for dir in $base_dir/target/kafka-rest-*-development; do | |
CLASSPATH=$CLASSPATH:$dir/share/java/kafka-rest/* | |
done | |
# Production jars | |
for library in "confluent-common" "rest-utils" "kafka-rest"; do | |
CLASSPATH=$CLASSPATH:$base_dir/share/java/$library/* | |
done | |
# logj4 settings | |
if [ "x$KAFKAREST_LOG4J_OPTS" = "x" ]; then | |
# Test for files from dev -> packages so this will work as expected in dev if you have packages | |
# installed | |
if [ -e "$base_dir/config/log4j.properties" ]; then # Dev environment | |
KAFKAREST_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/config/log4j.properties" | |
elif [ -e "$base_dir/etc/kafka-rest/log4j.properties" ]; then # Simple zip file layout | |
KAFKAREST_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/etc/kafka-rest/log4j.properties" | |
elif [ -e "/etc/kafka-rest/log4j.properties" ]; then # Normal install layout | |
KAFKAREST_LOG4J_OPTS="-Dlog4j.configuration=file:/etc/kafka-rest/log4j.properties" | |
fi | |
fi | |
# JMX settings | |
if [ -z "$KAFKAREST_JMX_OPTS" ]; then | |
KAFKAREST_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false " | |
fi | |
# JMX port to use | |
if [ $JMX_PORT ]; then | |
KAFKAREST_JMX_OPTS="$KAFKAREST_JMX_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT " | |
fi | |
# Generic jvm settings you want to add | |
if [ -z "$KAFKAREST_OPTS" ]; then | |
KAFKAREST_OPTS="" | |
fi | |
if [ "x$KAFKA_DEBUG" != "x" ]; then | |
# Use default ports | |
DEFAULT_JAVA_DEBUG_PORT="5005" | |
if [ -z "$JAVA_DEBUG_PORT" ]; then | |
JAVA_DEBUG_PORT="$DEFAULT_JAVA_DEBUG_PORT" | |
fi | |
# Use the defaults if JAVA_DEBUG_OPTS was not set | |
DEFAULT_JAVA_DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=${DEBUG_SUSPEND_FLAG:-n},address=$JAVA_DEBUG_PORT" | |
if [ -z "$JAVA_DEBUG_OPTS" ]; then | |
JAVA_DEBUG_OPTS="$DEFAULT_JAVA_DEBUG_OPTS" | |
fi | |
echo "Enabling Java debug options: $JAVA_DEBUG_OPTS" | |
KAFKAREST_OPTS="$JAVA_DEBUG_OPTS $KAFKA_OPTS" | |
fi | |
# Which java to use | |
if [ -z "$JAVA_HOME" ]; then | |
JAVA="java" | |
else | |
JAVA="$JAVA_HOME/bin/java" | |
fi | |
# Memory options | |
if [ -z "$KAFKAREST_HEAP_OPTS" ]; then | |
KAFKAREST_HEAP_OPTS="-Xmx256M" | |
fi | |
# JVM performance options | |
if [ -z "$KAFKAREST_JVM_PERFORMANCE_OPTS" ]; then | |
KAFKAREST_JVM_PERFORMANCE_OPTS="-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true" | |
fi | |
MAIN=$1 | |
shift | |
while [ $# -gt 0 ]; do | |
COMMAND=$1 | |
case $COMMAND in | |
-help) | |
HELP="true" | |
shift | |
;; | |
-daemon) | |
DAEMON_MODE="true" | |
shift | |
;; | |
*) | |
break | |
;; | |
esac | |
done | |
if [ "x$HELP" = "xtrue" ]; then | |
echo "USAGE: $0 [-daemon] [opts] [-help]" | |
exit 0 | |
fi | |
# Launch mode | |
if [ "x$DAEMON_MODE" = "xtrue" ]; then | |
nohup $JAVA $KAFKAREST_HEAP_OPTS $KAFKAREST_JVM_PERFORMANCE_OPTS $KAFKAREST_JMX_OPTS $KAFKAREST_LOG4J_OPTS -cp $CLASSPATH $KAFKAREST_OPTS "$MAIN" "$@" 2>&1 < /dev/null & | |
else | |
exec $JAVA $KAFKAREST_HEAP_OPTS $KAFKAREST_JVM_PERFORMANCE_OPTS $KAFKAREST_JMX_OPTS $KAFKAREST_LOG4J_OPTS -cp $CLASSPATH $KAFKAREST_OPTS "$MAIN" "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment