From 275209a8935c366bd845922096f71f1bc9495315 Mon Sep 17 00:00:00 2001 From: Sriharsha Chintalapani Date: Thu, 8 Jan 2015 07:50:20 -0800 Subject: [PATCH 1/2] KAFKA-1566. Kafka environment configuration (kafka-env.sh). --- bin/kafka-run-class.sh | 11 +++++++++++ bin/windows/kafka-run-class.bat | 15 +++++++++++++++ config/kafka-env.cmd | 23 +++++++++++++++++++++++ config/kafka-env.sh | 24 ++++++++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 config/kafka-env.cmd create mode 100644 config/kafka-env.sh diff --git a/bin/kafka-run-class.sh b/bin/kafka-run-class.sh index 881f578..4af69c8 100755 --- a/bin/kafka-run-class.sh +++ b/bin/kafka-run-class.sh @@ -22,6 +22,17 @@ fi base_dir=$(dirname $0)/.. +# run kafka-env.sh +KAFKA_ENV=$base_dir/config/kafka-env.sh +if [ -f $KAFKA_ENV ]; then + . $KAFKA_ENV +fi + +if [ ! -f $JAVA_HOME/bin/java ]; then + echo "Error: JAVA_HOME is incorrectly set." + exit +fi + # create logs directory if [ "x$LOG_DIR" = "x" ]; then LOG_DIR="$base_dir/logs" diff --git a/bin/windows/kafka-run-class.bat b/bin/windows/kafka-run-class.bat index 9df3d2b..56cb663 100644 --- a/bin/windows/kafka-run-class.bat +++ b/bin/windows/kafka-run-class.bat @@ -27,6 +27,20 @@ set BASE_DIR=%CD% popd set CLASSPATH= +IF exist %BASE_DIR%\config\kafka-env.cmd ( + call %BASE_DIR%\config\kafka-env.cmd +) + +IF not exist %JAVA_HOME%\bin\java.exe ( + echo Error: JAVA_HOME is incorrectly set. + goto :eof +) + + +IF ["%LOG_DIR%"] EQU [""] ( + set LOG_DIR=%BASE_DIR%\logs +) + IF ["%SCALA_VERSION%"] EQU [""] ( set SCALA_VERSION=2.10.4 ) @@ -89,6 +103,7 @@ rem Log4j settings IF ["%KAFKA_LOG4J_OPTS%"] EQU [""] ( set KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:%BASE_DIR%/config/tools-log4j.properties ) +set KAFKA_LOG4J_OPTS=-Dkafka.logs.dir=%LOG_DIR% %KAFKA_LOG4J_OPTS% rem Generic jvm settings you want to add IF ["%KAFKA_OPTS%"] EQU [""] ( diff --git a/config/kafka-env.cmd b/config/kafka-env.cmd new file mode 100644 index 0000000..a9bccbb --- /dev/null +++ b/config/kafka-env.cmd @@ -0,0 +1,23 @@ +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +rem The kafka env config command script +rem It allows users to override JAVA_HOME, LOG_DIR etc.. + +rem Set Kafka specific environment variables here. + +rem The java implementation to use. +set JAVA_HOME=%JAVA_HOME% diff --git a/config/kafka-env.sh b/config/kafka-env.sh new file mode 100644 index 0000000..efcc36b --- /dev/null +++ b/config/kafka-env.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Copyright 2014 The Apache Software Foundation +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Set Kafka specific environment variables here. + +# The java implementation to use. +export JAVA_HOME=${JAVA_HOME} -- 1.9.5 (Apple Git-50.3) From c89b9f01e09673d2257203503ef9d22f3c598632 Mon Sep 17 00:00:00 2001 From: Sriharsha Chintalapani Date: Tue, 17 Mar 2015 17:14:41 -0700 Subject: [PATCH 2/2] KAFKA-1566. Kafka environment configuration (kafka-env.sh). --- bin/windows/kafka-run-class.bat | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/windows/kafka-run-class.bat b/bin/windows/kafka-run-class.bat index 56cb663..6c1035e 100644 --- a/bin/windows/kafka-run-class.bat +++ b/bin/windows/kafka-run-class.bat @@ -27,16 +27,15 @@ set BASE_DIR=%CD% popd set CLASSPATH= -IF exist %BASE_DIR%\config\kafka-env.cmd ( +IF exist "%BASE_DIR%\config\kafka-env.cmd" ( call %BASE_DIR%\config\kafka-env.cmd ) -IF not exist %JAVA_HOME%\bin\java.exe ( +IF not exist "%JAVA_HOME%\bin\java.exe" ( echo Error: JAVA_HOME is incorrectly set. goto :eof ) - IF ["%LOG_DIR%"] EQU [""] ( set LOG_DIR=%BASE_DIR%\logs ) -- 1.9.5 (Apple Git-50.3)