Skip to content

Commit

Permalink
fixed #114
Browse files Browse the repository at this point in the history
  • Loading branch information
garyelephant committed Mar 25, 2018
1 parent fa54e2a commit 889f01c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/start-waterdrop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ LIB_DIR=${APP_DIR}/lib
PLUGINS_DIR=${APP_DIR}/plugins

DEFAULT_CONFIG=${CONF_DIR}/application.conf
CONFIG_FILE=${CONFIG_FILE:-DEFAULT_CONFIG}
CONFIG_FILE=${CONFIG_FILE:-$DEFAULT_CONFIG}

DEFAULT_MASTER=local[2]
MASTER=${MASTER:-$DEFAULT_MASTER}
Expand All @@ -62,6 +62,7 @@ DEPLOY_MODE=${DEPLOY_MODE:-$DEFAULT_DEPLOY_MODE}

# scan jar dependencies for all plugins
source ${UTILS_DIR}/file.sh
source ${UTILS_DIR}/app.sh
jarDependencies=$(listJarDependenciesOfPlugins ${PLUGINS_DIR})
JarDepOpts=""
if [ "$jarDependencies" != "" ]; then
Expand Down Expand Up @@ -89,6 +90,7 @@ assemblyJarName=$(find ${LIB_DIR} -name Waterdrop-*.jar)
source ${CONF_DIR}/waterdrop-env.sh

exec ${SPARK_HOME}/bin/spark-submit --class io.github.interestinglab.waterdrop.Waterdrop \
--name $(getAppName ${CONFIG_FILE}) \
--master ${MASTER} \
--deploy-mode ${DEPLOY_MODE} \
${JarDepOpts} \
Expand Down
32 changes: 32 additions & 0 deletions bin/utils/app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Get App Name of Waterdrop
function getAppName {

if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit -1
fi

config_file_path=$1

app_name_config=$(grep -i "spark.app.name" ${config_file_path})
# remove all leading and trailing whitespace
app_name_config=$(echo ${app_name_config} | tr -d '[:space:]')

DEFAULT_APP_NAME="Waterdrop"
APP_NAME=${DEFAULT_APP_NAME}

if [[ ${app_name_config} == \#* ]]; then
# spark.app.name is commented, we should ignore
:
else

if [ "${app_name_config}" != "" ];then
# split app_name from config
APP_NAME=${app_name_config##*=}
# remove quotes if exists
APP_NAME=$(echo ${APP_NAME} | tr -d '"' | tr -d "'")
fi
fi

echo ${APP_NAME}
}

0 comments on commit 889f01c

Please sign in to comment.