Skip to content

Commit

Permalink
[fix][env]Fix wrongly set jvm gc log dir (apache#15449)
Browse files Browse the repository at this point in the history
* Fix error set jvm gc log dir

* fix unit test

Co-authored-by: gavingaozhangmin <[email protected]>
  • Loading branch information
gaozhangmin and gavingaozhangmin authored May 20, 2022
1 parent e2fa189 commit f3c072e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bin/pulsar
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ then
fi

# Check pulsar env and load pulsar_env.sh
if [ -f "$PULSAR_HOME/conf/pulsar_env.sh" ]
if [[ -f "$PULSAR_HOME/conf/pulsar_env.sh" && $1 != "bookie" ]]
then
. "$PULSAR_HOME/conf/pulsar_env.sh"
fi
Expand Down
7 changes: 4 additions & 3 deletions bin/pulsar-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ shift
if [[ "$command" = "bookie" ]]
then
PULSAR_LOG_DIR=${BOOKIE_LOG_DIR:-"$PULSAR_HOME/logs"}
PULSAR_PID_DIR=${BOOKIE_PID_DIR:-"$PULSAR_HOME/bin"}
else
PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"}
PULSAR_PID_DIR=${PULSAR_PID_DIR:-"$PULSAR_HOME/bin"}
fi
PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"RollingFile"}
PULSAR_STOP_TIMEOUT=${PULSAR_STOP_TIMEOUT:-30}
PULSAR_PID_DIR=${PULSAR_PID_DIR:-$PULSAR_HOME/bin}
mkdir -p "$PULSAR_LOG_DIR"
mkdir -p "$PULSAR_PID_DIR"

case $command in
(broker)
Expand Down Expand Up @@ -213,8 +216,6 @@ stop ()
fi
}

mkdir -p "$PULSAR_LOG_DIR"

case $startStop in
(start)
start "$*"
Expand Down
5 changes: 3 additions & 2 deletions conf/bkenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ else
IS_JAVA_8=`$JAVA_HOME/bin/java -version 2>&1 |grep version|grep '"1\.8'`
fi

BOOKIE_GC_LOG_DIR=${BOOKIE_LOG_DIR:-"logs"}
# java version has space, use [[ -n $PARAM ]] to judge if variable exists
if [[ -n $IS_JAVA_8 ]]; then
BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-${PULSAR_GC_LOG:-"-Xloggc:logs/pulsar_bookie_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M"}}
BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-${PULSAR_GC_LOG:-"-Xloggc:$BOOKIE_GC_LOG_DIR/pulsar_bookie_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M"}}
else
# After jdk 9, gc log param should config like this. Ignoring version less than jdk 8
BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-${PULSAR_GC_LOG:-"-Xlog:gc*:logs/pulsar_bookie_gc_%p.log:time,uptime,level,tags:filecount=10,filesize=20M"}}
BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-${PULSAR_GC_LOG:-"-Xlog:gc*:$BOOKIE_GC_LOG_DIR/pulsar_bookie_gc_%p.log:time,uptime,level,tags:filecount=10,filesize=20M"}}
fi

# Extra options to be passed to the jvm
Expand Down
5 changes: 3 additions & 2 deletions conf/pulsar_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ else
IS_JAVA_8=`$JAVA_HOME/bin/java -version 2>&1 |grep version|grep '"1\.8'`
fi
# java version has space, use [[ -n $PARAM ]] to judge if variable exists
PULSAR_GC_LOG_DIR=${PULSAR_LOG_DIR:-"logs"}
if [[ -n $IS_JAVA_8 ]]; then
PULSAR_GC_LOG=${PULSAR_GC_LOG:-"-Xloggc:logs/pulsar_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M"}
PULSAR_GC_LOG=${PULSAR_GC_LOG:-"-Xloggc:$PULSAR_GC_LOG_DIR/pulsar_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M"}
else
# After jdk 9, gc log param should config like this. Ignoring version less than jdk 8
PULSAR_GC_LOG=${PULSAR_GC_LOG:-"-Xlog:gc*:logs/pulsar_gc_%p.log:time,uptime:filecount=10,filesize=20M"}
PULSAR_GC_LOG=${PULSAR_GC_LOG:-"-Xlog:gc*:$PULSAR_GC_LOG_DIR/pulsar_gc_%p.log:time,uptime:filecount=10,filesize=20M"}
fi

# Extra options to be passed to the jvm
Expand Down

0 comments on commit f3c072e

Please sign in to comment.