git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@959043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2010-06-29 17:19:27 +00:00
parent 4a23f0d1c1
commit 149d4772df
1 changed files with 32 additions and 29 deletions

View File

@ -38,7 +38,7 @@ COMMANDLINE_ARGS="$@"
if ( basename $0 | grep -q "activemq-instance-" );then
INST="$(basename $0|sed 's/^activemq-instance-//;s/\.sh$//')"
ACTIVEMQ_CONFIGS="/etc/default/activemq-instance-${INST} $HOME/.activemqrc-instance-${INST}"
echo "INFO: using alternative activemq configuration files: $ACCTIVEMQ_CONFIGS"
echo "INFO: Using alternative activemq configuration files: $ACCTIVEMQ_CONFIGS"
fi
## START:DEFAULTCONFIG
@ -174,10 +174,10 @@ for ACTIVEMQ_CONFIG in $ACTIVEMQ_CONFIGS;do
if [ -f "$ACTIVEMQ_CONFIG" ] ; then
( . $ACTIVEMQ_CONFIG >/dev/null 2>&1 )
if [ "$?" != "0" ];then
echo "ERROR: there are syntax errors in '$ACTIVEMQ_CONFIG'"
echo "ERROR: There are syntax errors in '$ACTIVEMQ_CONFIG'"
exit 1
else
echo "INFO: loading '$ACTIVEMQ_CONFIG'"
echo "INFO: Loading '$ACTIVEMQ_CONFIG'"
. $ACTIVEMQ_CONFIG
CONFIG_LOAD="yes"
fi
@ -187,10 +187,10 @@ done
# inform user that default configuration is loaded, no suitable configfile found
if [ "$CONFIG_LOAD" != "yes" ];then
if [ "$1" != "setup" ];then
echo "INFO: using default configuration";
echo "INFO: Using default configuration";
echo "(you can configure options in one of these file: $ACTIVEMQ_CONFIGS)"
echo
echo "INFO: invoke the following command to create a configuration file"
echo "INFO: Invoke the following command to create a configuration file"
echo "$0 setup [ $(echo $ACTIVEMQ_CONFIGS|sed 's/[ ][ ]*/ | /') ]"
echo
fi
@ -199,10 +199,10 @@ fi
# create configuration if requested
if [ "$1" = "setup" ];then
if [ -z "$2" ];then
echo "ERROR: specify configuration file"
echo "ERROR: Specify configuration file"
exit 1
fi
echo "INFO: creating configuration file: $2"
echo "INFO: Creating configuration file: $2"
(
P_STATE="0"
while read LINE ;do
@ -219,7 +219,7 @@ if [ "$1" = "setup" ];then
fi
done < $0
) > $2
echo "INFO: it's recommend to limit access to '$2' to the priviledged user"
echo "INFO: It's recommend to limit access to '$2' to the priviledged user"
echo "INFO: (recommended: chown `whoami`:nogroup '$2'; chmod 600 '$2')"
exit $?
fi
@ -270,12 +270,12 @@ if [ ! -x "$JAVACMD" ] ; then
fi
# Stop here if no java installation is defined/found
if [ ! -x "$JAVACMD" ] ; then
echo "ERROR: configuration varaiable JAVA_HOME or JAVACMD is not defined correctly."
echo "ERROR: Configuration varaiable JAVA_HOME or JAVACMD is not defined correctly."
echo " (JAVA_HOME='$JAVAHOME', JAVACMD='$JAVACMD')"
exit 1
fi
echo "INFO: using java '$JAVACMD'"
echo "INFO: Using java '$JAVACMD'"
if [ -z "$ACTIVEMQ_BASE" ] ; then
ACTIVEMQ_BASE="$ACTIVEMQ_HOME"
@ -368,7 +368,7 @@ invokeJar(){
checkRunning(){
if [ -f "$ACTIVEMQ_PIDFILE" ]; then
if [ -z "$(cat $ACTIVEMQ_PIDFILE)" ];then
echo "ERROR: pidfile '$ACTIVEMQ_PIDFILE' exists but contains no pid"
echo "ERROR: Pidfile '$ACTIVEMQ_PIDFILE' exists but contains no pid"
return 2
fi
if (ps -p $(cat $ACTIVEMQ_PIDFILE)|grep java >/dev/null);then
@ -392,10 +392,10 @@ checkRunning(){
invoke_status(){
if ( checkRunning );then
echo "Activemq is running (pid '$(cat $ACTIVEMQ_PIDFILE)')"
echo "ActiveMQ is running (pid '$(cat $ACTIVEMQ_PIDFILE)')"
exit 0
fi
echo "Activemq not running"
echo "ActiveMQ not running"
exit 1
}
@ -412,7 +412,7 @@ invoke_status(){
invoke_start(){
if ( checkRunning );then
echo "INFO: process with pid '$(cat $ACTIVEMQ_PIDFILE)' is already running"
echo "INFO: Process with pid '$(cat $ACTIVEMQ_PIDFILE)' is already running"
exit 0
fi
@ -420,7 +420,7 @@ invoke_start(){
ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY -Dorg.apache.activemq.UseDedicatedTaskRunner=true -Djava.util.logging.config.file=logging.properties"
fi
ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS $ACTIVEMQ_SUNJMX_START $ACTIVEMQ_SSL_OPTS"
echo "INFO: starting - inspect logfiles specified in logging.properties and log4j.properties to get details"
echo "INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details"
invokeJar $ACTIVEMQ_PIDFILE
exit "$?"
}
@ -438,7 +438,7 @@ invoke_start(){
invoke_fgstart(){
if ( checkRunning );then
echo "ERROR: activemq is already running"
echo "ERROR: ActiveMQ is already running"
exit 1
fi
if [ -z "$ACTIVEMQ_OPTS" ] ; then
@ -447,7 +447,7 @@ invoke_fgstart(){
ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS $ACTIVEMQ_SUNJMX_START $ACTIVEMQ_SSL_OPTS"
COMMANDLINE_ARGS="start $(echo $COMMANDLINE_ARGS|sed 's,^fgstart,,')"
echo "INFO: starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+c)"
echo "INFO: Starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+C)"
invokeJar
exit "$?"
}
@ -469,7 +469,7 @@ invoke_stop(){
COMMANDLINE_ARGS="$COMMANDLINE_ARGS $ACTIVEMQ_SUNJMX_CONTROL"
invokeJar
RET="$?"
echo -n "INFO: waiting at least $ACTIVEMQ_KILL_MAXSECONDS seconds for regular process termination of pid '$(cat $ACTIVEMQ_PIDFILE)' : "
echo -n "INFO: Waiting at least $ACTIVEMQ_KILL_MAXSECONDS seconds for regular process termination of pid '$(cat $ACTIVEMQ_PIDFILE)' : "
FOUND="0"
# for i in `seq 0 $ACTIVEMQ_KILL_MAXSECONDS` ;do
for i in {1..$ACTIVEMQ_KILL_MAXSECONDS} ;do
@ -483,15 +483,16 @@ invoke_stop(){
fi
done
if [ "$FOUND" -ne "1" ];then
echo "INFO: regular shutdown not successful, sending SIGKILL to process with pid '$(cat $ACTIVEMQ_PIDFILE)'"
echo "INFO: Regular shutdown not successful, sending SIGKILL to process with pid '$(cat $ACTIVEMQ_PIDFILE)'"
kill -KILL $(cat $ACTIVEMQ_PIDFILE)
RET="1"
fi
elif [ -f "$ACTIVEMQ_PIDFILE" ];then
echo "ERROR: no or outdated process id in '$ACTIVEMQ_PIDFILE'"
echo "ERROR: No or outdated process id in '$ACTIVEMQ_PIDFILE'"
echo
echo "INFO: removing $ACTIVEMQ_PIDFILE"
echo "INFO: Removing $ACTIVEMQ_PIDFILE"
else
echo "ActiveMQ not running"
exit 0
fi
rm -f $ACTIVEMQ_PIDFILE >/dev/null 2>&1
@ -524,16 +525,12 @@ invoke_task(){
invokeJar
exit $?
else
echo "INFO: activemq not running"
invokeJar
exit 1
fi
}
# ------------------------------------------------------------------------
# MAIN
# show help
if [ -z "$1" ];then
show_help() {
invokeJar
RET="$?"
cat << EOF
@ -552,6 +549,14 @@ Configuration of this script:
\$HOME/.activemqrc-instance-<INSTANCENAME>. Configuration files in /etc have higher precedence.
EOF
exit $RET
}
# ------------------------------------------------------------------------
# MAIN
# show help
if [ -z "$1" ];then
show_help
fi
case "$1" in
@ -578,5 +583,3 @@ case "$1" in
*)
invoke_task
esac
# vim:ai et ts=2 shiftwidth=2 expandtab tabstop=3: