Skip to content

Commit

Permalink
Solve #665, Merge start-agent.sh into start-smart.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
littlezhou committed Jul 27, 2017
1 parent 8aa8d57 commit 2086295
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 83 deletions.
10 changes: 9 additions & 1 deletion bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,19 @@ function init_command() {
SMART_PID_FILE=/tmp/SmartServer.pid
ALLOW_DAEMON_OPT=true
SMART_VARGS+=" -format"
;;
JAVA_OPTS+=" -Dsmart.log.file=SmartServer.log"
;;
smartserver)
SMART_CLASSNAME=org.smartdata.server.SmartDaemon
SMART_PID_FILE=/tmp/SmartServer.pid
ALLOW_DAEMON_OPT=true
JAVA_OPTS+=" -Dsmart.log.file=SmartServer.log"
;;
smartagent)
SMART_CLASSNAME=org.smartdata.agent.SmartAgent
SMART_PID_FILE=/tmp/SmartAgent.pid
ALLOW_DAEMON_OPT=true
JAVA_OPTS+=" -Dsmart.log.file=SmartAgent.log"
;;
getconf)
SMART_CLASSNAME=org.smartdata.server.utils.tools.GetConf
Expand Down
5 changes: 3 additions & 2 deletions bin/smart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ SMART_VARGS="$@"
init_command ${COMMAND}

JAVA_OPTS+=" -Dsmart.log.dir=${SMART_LOG_DIR}"
JAVA_OPTS+=" -Dsmart.log.file=SmartServer.log"

JAVA_VERSION=$($SMART_RUNNER -version 2>&1 | awk -F '.' '/version/ {print $2}')

Expand All @@ -98,6 +97,7 @@ fi

addJarInDir "${SMART_HOME}/smart-server/target/lib"
addNonTestJarInDir "${SMART_HOME}/smart-server/target"
addNonTestJarInDir "${SMART_HOME}/smart-agent/target"
addJarInDir "${SMART_HOME}/lib"

if [ "$SMART_CLASSPATH" = "" ]; then
Expand Down Expand Up @@ -142,5 +142,6 @@ else
else
local_execute
fi
exit $?
fi
exit $?

76 changes: 0 additions & 76 deletions bin/start-agent.sh

This file was deleted.

23 changes: 21 additions & 2 deletions bin/start-smart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ done
SMARTSERVERS=$("${SMART_HOME}/bin/smart" getconf SmartServers 2>/dev/null)

if [ "$?" != "0" ]; then
echo "${SMARTSERVERS}"
echo "ERROR: Get SmartServers error: ${SMARTSERVERS}"
exit 1
fi

Expand All @@ -69,5 +69,24 @@ if [ x"${SMARTSERVERS}" != x"" ]; then
--daemon start ${DEBUG_OPT} \
smartserver
else
echo "No SmartServers configured in 'hazelcast.xml'."
echo "WARN: No SmartServers configured in 'hazelcast.xml'."
fi

echo

#---------------------------------------------------------
# Start Smart Agents

AGENTS_FILE="${SMART_CONF_DIR}/agents"
if [ -f "${AGENTS_FILE}" ]; then
AGENT_HOSTS=$(sed 's/#.*$//;/^$/d' "${AGENTS_FILE}" | xargs echo)
if [ x"${AGENT_HOSTS}" != x"" ]; then
echo "Starting SmartAgents on [${AGENT_HOSTS}]"
. "${SMART_HOME}/bin/smart" \
--remote \
--config "${SMART_CONF_DIR}" \
--hosts "${AGENT_HOSTS}" --hostsend \
--daemon start ${DEBUG_OPT} \
smartagent
fi
fi
23 changes: 21 additions & 2 deletions bin/stop-smart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ done
SMARTSERVERS=$("${SMART_HOME}/bin/smart" getconf SmartServers 2>/dev/null)

if [ "$?" != "0" ]; then
echo "${SMARTSERVERS}"
exit 1
echo "ERROR: Get SmartServers error: ${SMARTSERVERS}"
exit 1
fi

if [ x"${SMARTSERVERS}" != x"" ]; then
Expand All @@ -67,3 +67,22 @@ if [ x"${SMARTSERVERS}" != x"" ]; then
else
echo "No SmartServers configured in 'hazelcast.xml'."
fi

echo

#---------------------------------------------------------
# Stop Smart Agents

AGENTS_FILE="${SMART_CONF_DIR}/agents"
if [ -f "${AGENTS_FILE}" ]; then
AGENT_HOSTS=$(sed 's/#.*$//;/^$/d' "${AGENTS_FILE}" | xargs echo)
if [ x"${AGENT_HOSTS}" != x"" ]; then
echo "Stopping SmartAgents on [${AGENT_HOSTS}]"
. "${SMART_HOME}/bin/smart" \
--remote \
--config "${SMART_CONF_DIR}" \
--hosts "${AGENT_HOSTS}" --hostsend \
--daemon stop ${DEBUG_OPT} \
smartagent
fi
fi
Empty file added conf/agents
Empty file.

0 comments on commit 2086295

Please sign in to comment.