This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solve #761, Refine boot scripts and provide standalone script for dat…
…abase formatting (#762)
- Loading branch information
1 parent
5b1d223
commit a4a69fe
Showing
5 changed files
with
288 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# 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. | ||
# | ||
|
||
bin=$(dirname "${BASH_SOURCE-$0}") | ||
bin=$(cd "${bin}">/dev/null; pwd) | ||
HOSTNAME=$(hostname) | ||
|
||
SMART_VARGS= | ||
while [ $# != 0 ]; do | ||
case "$1" in | ||
"--config") | ||
shift | ||
conf_dir="$1" | ||
if [[ ! -d "${conf_dir}" ]]; then | ||
echo "ERROR : ${conf_dir} is not a directory" | ||
echo ${USAGE} | ||
exit 1 | ||
else | ||
export SMART_CONF_DIR="${conf_dir}" | ||
echo "SMART_CONF_DIR="$SMART_CONF_DIR | ||
fi | ||
shift | ||
;; | ||
*) | ||
SMART_VARGS+=" $1" | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
. "${bin}/common.sh" | ||
|
||
#--------------------------------------------------------- | ||
# | ||
|
||
echo -n "Start formatting database ... " | ||
|
||
$("${SMART_HOME}/bin/smart" --config "${SMART_CONF_DIR}" formatdatabase 2>/dev/null) | ||
|
||
if [ x"$?" = x"0" ]; then | ||
echo "[Success]" | ||
else | ||
echo "[Failed]" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# 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. | ||
# | ||
|
||
Usage="smart --config <config dir> [--daemon] [--hosts <hostA> <hostB> --hostsend] [--daemon start|stop ] [--remote] <command> <command args>" | ||
|
||
SCRIPT_ARGS="$*" | ||
|
||
bin=$(dirname "${BASH_SOURCE-$0}") | ||
bin=$(cd "${bin}">/dev/null; pwd) | ||
HOSTNAME=$(hostname) | ||
|
||
REMOTE_COMMAND= | ||
DAEMON_MOD= | ||
DAEMON_MOD_OP= | ||
REMOTE_MODE= | ||
SMART_VARGS= | ||
while [ $# != 0 ]; do | ||
case "$1" in | ||
"--config") | ||
shift | ||
conf_dir="$1" | ||
if [[ ! -d "${conf_dir}" ]]; then | ||
echo "ERROR : ${conf_dir} is not a directory" | ||
echo ${USAGE} | ||
exit 1 | ||
else | ||
export SMART_CONF_DIR="${conf_dir}" | ||
fi | ||
REMOTE_COMMAND+=" --config $1" | ||
shift | ||
;; | ||
"--debug") | ||
JAVA_OPTS+=" -Xdebug -Xrunjdwp:transport=dt_socket,address=8008,server=y,suspend=y" | ||
REMOTE_COMMAND+=" $1" | ||
shift | ||
;; | ||
"--daemon") | ||
REMOTE_COMMAND+=" $1 $2" | ||
DAEMON_MOD=true | ||
shift | ||
DAEMON_MOD_OP=$1 | ||
shift | ||
;; | ||
"--remote") | ||
REMOTE_MODE=true | ||
shift | ||
;; | ||
"--hosts") | ||
SMART_HOSTS= | ||
shift | ||
while [ x"$1" != x"--hostsend" ]; do | ||
SMART_HOSTS+=" $1" | ||
shift | ||
done | ||
shift | ||
;; | ||
*) | ||
break; | ||
;; | ||
esac | ||
done | ||
|
||
REMOTE_COMMAND+=" $@" | ||
COMMAND=$1 | ||
shift | ||
SMART_VARGS="$@" | ||
|
||
. "${bin}/common.sh" | ||
|
||
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}') | ||
|
||
if [[ "$JAVA_VERSION" -ge 8 ]]; then | ||
JAVA_OPTS+=" -XX:MaxMetaspaceSize=256m" | ||
else | ||
JAVA_OPTS+=" -XX:MaxPermSize=256m" | ||
fi | ||
|
||
addJarInDir "${SMART_HOME}/smart-server/target/lib" | ||
addNonTestJarInDir "${SMART_HOME}/smart-server/target" | ||
addJarInDir "${SMART_HOME}/lib" | ||
|
||
if [ "$SMART_CLASSPATH" = "" ]; then | ||
SMART_CLASSPATH="${SMART_CONF_DIR}" | ||
else | ||
SMART_CLASSPATH="${SMART_CONF_DIR}:${SMART_CLASSPATH}" | ||
fi | ||
|
||
if [[ ! -d "${SMART_LOG_DIR}" ]]; then | ||
$(mkdir -p "${SMART_LOG_DIR}") | ||
fi | ||
|
||
SMART_VARGS+=" -D smart.conf.dir="${SMART_CONF_DIR} | ||
SMART_VARGS+=" -D smart.log.dir="${SMART_LOG_DIR} | ||
|
||
|
||
#echo "$SMART_RUNNER $JAVA_OPTS -cp ${SMART_CLASSPATH} ${SMART_CLASSNAME} $@" | ||
|
||
#exec $SMART_RUNNER $JAVA_OPTS -cp "${SMART_CLASSPATH}" ${SMART_CLASSNAME} $@ | ||
|
||
if [ x"${REMOTE_MODE}" = x"true" ]; then | ||
for host in $SMART_HOSTS | ||
do | ||
echo "Processing on '${host}' ... " | ||
remote_execute ${host} ${SMART_HOME}/bin/smart ${REMOTE_COMMAND} | ||
if [ "$?" = "0" ]; then | ||
echo "Processing on '${host}' completed successfully." | ||
else | ||
echo "ERROR: Processing on '${host}' failed." | ||
fi | ||
done | ||
else | ||
if [ x"${DAEMON_MOD}" = x"true" ]; then | ||
case "${DAEMON_MOD_OP}" in | ||
"start") | ||
smart_start_daemon ${SMART_PID_FILE} | ||
;; | ||
"stop") | ||
smart_stop_daemon ${SMART_PID_FILE} | ||
;; | ||
esac | ||
else | ||
local_execute | ||
fi | ||
fi | ||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.