Skip to content

Commit

Permalink
Optimize the bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
zuston committed Jul 5, 2022
1 parent 8256765 commit 060f07d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 20 deletions.
21 changes: 11 additions & 10 deletions bin/start-coordinator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ cd $COORDINATOR_HOME
source "${COORDINATOR_HOME}/bin/rss-env.sh"
source "${COORDINATOR_HOME}/bin/utils.sh"

if [ -z "$HADOOP_HOME" ]; then
echo "No env HADOOP_HOME."
exit 1
fi

HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
HADOOP_DEPENDENCY=$HADOOP_HOME/etc/hadoop:$HADOOP_HOME/share/hadoop/common/lib/*:$HADOOP_HOME/share/hadoop/common/*:$HADOOP_HOME/share/hadoop/hdfs:$HADOOP_HOME/share/hadoop/hdfs/lib/*:$HADOOP_HOME/share/hadoop/hdfs/*:$HADOOP_HOME/share/hadoop/yarn/lib/*:$HADOOP_HOME/share/hadoop/yarn/*:$HADOOP_HOME/share/hadoop/mapreduce/lib/*:$HADOOP_HOME/share/hadoop/mapreduce/*
HADOOP_DEPENDENCY=`$HADOOP_HOME/bin/hadoop classpath --glob`

echo "Check process existence"
is_jvm_process_running $JPS $MAIN_CLASS
Expand All @@ -45,11 +50,6 @@ for file in $(ls ${JAR_DIR}/coordinator/*.jar 2>/dev/null); do
CLASSPATH=$CLASSPATH:$file
done

if [ -z "$HADOOP_HOME" ]; then
echo "No env HADOOP_HOME."
exit 1
fi

if [ -z "$HADOOP_CONF_DIR" ]; then
echo "No env HADOOP_CONF_DIR."
exit 1
Expand All @@ -71,13 +71,14 @@ JVM_ARGS=" -server \
-XX:InitiatingHeapOccupancyPercent=45 "

ARGS=""
if [ -f ./conf/log4j.properties ]; then
ARGS="$ARGS -Dlog4j.configuration=file:./conf/log4j.properties"

LOG_CONF_FILE="./conf/log4j.coordinator.properties"
if [ -f ${LOG_CONF_FILE} ]; then
ARGS="$ARGS -Dlog4j.configuration=file:${LOG_CONF_FILE}"
else
echo "Exit with error: $conf/log4j.properties file doesn't exist."
echo "Exit with error: ${LOG_CONF_FILE} file doesn't exist."
exit 1
fi

$RUNNER $ARGS $JVM_ARGS -cp $CLASSPATH $MAIN_CLASS --conf $CONF_FILE $@ &

echo $! >$COORDINATOR_HOME/currentpid
20 changes: 11 additions & 9 deletions bin/start-shuffle-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ cd $SHUFFLE_SERVER_HOME
source "${SHUFFLE_SERVER_HOME}/bin/rss-env.sh"
source "${SHUFFLE_SERVER_HOME}/bin/utils.sh"

if [ -z "$HADOOP_HOME" ]; then
echo "No env HADOOP_HOME."
exit 1
fi

HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
HADOOP_DEPENDENCY=$HADOOP_HOME/etc/hadoop:$HADOOP_HOME/share/hadoop/common/lib/*:$HADOOP_HOME/share/hadoop/common/*:$HADOOP_HOME/share/hadoop/hdfs:$HADOOP_HOME/share/hadoop/hdfs/lib/*:$HADOOP_HOME/share/hadoop/hdfs/*:$HADOOP_HOME/share/hadoop/yarn/lib/*:$HADOOP_HOME/share/hadoop/yarn/*:$HADOOP_HOME/share/hadoop/mapreduce/lib/*:$HADOOP_HOME/share/hadoop/mapreduce/*
HADOOP_DEPENDENCY=`$HADOOP_HOME/bin/hadoop classpath --glob`

CONF_FILE="./conf/server.conf "
MAIN_CLASS="org.apache.uniffle.server.ShuffleServer"
Expand All @@ -46,11 +51,6 @@ for file in $(ls ${JAR_DIR}/server/*.jar 2>/dev/null); do
CLASSPATH=$CLASSPATH:$file
done

if [ -z "$HADOOP_HOME" ]; then
echo "No env HADOOP_HOME."
exit 1
fi

if [ -z "$HADOOP_CONF_DIR" ]; then
echo "No env HADOOP_CONF_DIR."
exit 1
Expand Down Expand Up @@ -85,10 +85,12 @@ JVM_ARGS=" -server \
-Xloggc:./logs/gc-%t.log"

ARGS=""
if [ -f ./conf/log4j.properties ]; then
ARGS="$ARGS -Dlog4j.configuration=file:./conf/log4j.properties"

LOG_CONF_FILE="./conf/log4j.shuffle_server.properties"
if [ -f ${LOG_CONF_FILE} ]; then
ARGS="$ARGS -Dlog4j.configuration=file:${LOG_CONF_FILE}"
else
echo "Exit with error: $conf/log4j.properties file doesn't exist."
echo "Exit with error: ${LOG_CONF_FILE} file doesn't exist."
exit 1
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
log4j.appender.RollingAppender=org.apache.log4j.RollingFileAppender
log4j.appender.RollingAppender.File=./logs/rss.log
log4j.appender.RollingAppender.File=./logs/coordinator.log
log4j.appender.RollingAppender.MaxFileSize=50MB
log4j.appender.RollingAppender.MaxBackupIndex=10
log4j.appender.RollingAppender.layout=org.apache.log4j.PatternLayout
Expand Down
29 changes: 29 additions & 0 deletions conf/log4j.shuffle_server.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# 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.
#

log4j.rootCategory=INFO, RollingAppender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=INFO
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
log4j.appender.RollingAppender=org.apache.log4j.RollingFileAppender
log4j.appender.RollingAppender.File=./logs/shuffle_server.log
log4j.appender.RollingAppender.MaxFileSize=50MB
log4j.appender.RollingAppender.MaxBackupIndex=10
log4j.appender.RollingAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.RollingAppender.layout.ConversionPattern=[%p] %d %t %c{1} %M - %m%n

0 comments on commit 060f07d

Please sign in to comment.