
org.apache.activemq.apollo.broker.bin.apollo-broker-service Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo-broker Show documentation
Show all versions of apollo-broker Show documentation
A reliable messaging server.
The newest version!
#!/bin/sh
#chkconfig: 2345 55 25
# ------------------------------------------------------------------------
# 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.
# ------------------------------------------------------------------------
APOLLO_USER="${user}"
service=`basename "$0"`
#
# Discover the APOLLO_BASE from the location of this script.
#
if [ -z "$APOLLO_BASE" ] ; then
## resolve links - $0 may be a link to apollo's home
PRG="$0"
saveddir=`pwd`
# need this for relative symlinks
dirname_prg=`dirname "$PRG"`
cd "$dirname_prg"
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '.*/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
APOLLO_BASE=`dirname "$PRG"`
cd "$saveddir"
# make it fully qualified
APOLLO_BASE=`cd "$APOLLO_BASE/.." && pwd`
export APOLLO_BASE
fi
PID_FILE="${APOLLO_BASE}/data/apollo.pid"
if [ -f "${APOLLO_BASE}/etc/apollo.profile" ] ; then
. "${APOLLO_BASE}/etc/apollo.profile"
fi
status() {
if [ -f "${PID_FILE}" ] ; then
pid=`cat "${PID_FILE}"`
# check to see if it's gone...
ps -p ${pid} > /dev/null
if [ $? -eq 0 ] ; then
return 0
else
rm "${PID_FILE}"
return 3
fi
fi
return 3
}
stop() {
if [ -f "${PID_FILE}" ] ; then
pid=`cat "${PID_FILE}"`
kill $@ ${pid} > /dev/null
fi
for i in 1 2 3 4 5 ; do
status
if [ $? -ne 0 ] ; then
return 0
fi
sleep 1
done
echo "Could not stop process ${pid}"
return 1
}
start() {
status
if [ $? -eq 0 ] ; then
echo "Already running."
return 1
fi
if [ -z "$APOLLO_USER" -o `id -un` = "$APOLLO_USER" ] ; then
nohup ${APOLLO_BASE}/bin/apollo-broker run > /dev/null 2> /dev/null &
else
sudo -n -u ${APOLLO_USER} nohup ${APOLLO_BASE}/bin/apollo-broker run > /dev/null 2> /dev/null &
fi
echo $! > "${PID_FILE}"
# check to see if stays up...
sleep 1
status
if [ $? -ne 0 ] ; then
echo "Could not start ${service}"
return 1
fi
echo "${service} is now running (${pid})"
return 0
}
case $1 in
start)
echo "Starting ${service}"
start
exit $?
;;
force-stop)
echo "Forcibly Stopping ${service}"
stop -9
exit $?
;;
stop)
echo "Gracefully Stopping ${service}"
stop
exit $?
;;
restart)
echo "Restarting ${service}"
stop
start
exit $?
;;
status)
status
rc=$?
if [ $rc -eq 0 ] ; then
echo "${service} is running (${pid})"
else
echo "${service} is stopped"
fi
exit $rc
;;
*)
echo "Usage: $0 {start|stop|restart|force-stop|status}" >&2
exit 2
;;
esac
© 2015 - 2025 Weber Informatics LLC | Privacy Policy