Skip to content

Commit

Permalink
[TUBEMQ-240] add status command for broker/master script (#167)
Browse files Browse the repository at this point in the history
Signed-off-by: Guangxu Cheng <gxcheng@apache.org>
Signed-off-by: gosonzhang <4675739@qq.com>
  • Loading branch information
dockerzhang committed Jun 19, 2020
1 parent c6d00d0 commit 734d6af
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
18 changes: 16 additions & 2 deletions bin/broker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ AS_USER=`whoami`
LOG_DIR="$BASE_DIR/logs"
LOG_FILE="$LOG_DIR/broker.log"
PID_DIR="$BASE_DIR/logs"
PID_FILE="$PID_DIR/.run.pid"
PID_FILE="$PID_DIR/.broker.run.pid"

function running(){
if [ -f "$PID_FILE" ]; then
Expand Down Expand Up @@ -83,6 +83,16 @@ function start_server() {
chmod 755 $PID_FILE
}

function status_server() {
if running; then
echo "Broker is running."
exit 0
else
echo "Broker is not running."
exit 1
fi
}

function stop_server() {
if ! running; then
echo "Broker is not running."
Expand All @@ -107,7 +117,8 @@ function stop_server() {
}

function help() {
echo "Usage: broker.sh {start|stop|restart}" >&2
echo "Usage: broker.sh {status|start|stop|restart}" >&2
echo " status: the status of broker server"
echo " start: start the broker server"
echo " stop: stop the broker server"
echo " restart: restart the broker server"
Expand All @@ -116,6 +127,9 @@ function help() {
command=$1
shift 1
case $command in
status)
status_server $@;
;;
start)
start_server $@;
;;
Expand Down
16 changes: 15 additions & 1 deletion bin/master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ function start_server() {
popd
}

function status_server() {
if running; then
echo "Master is running."
exit 0
else
echo "Master is not running."
exit 1
fi
}

function stop_server() {
if ! running; then
echo "Master is not running."
Expand All @@ -111,7 +121,8 @@ function stop_server() {
}

function help() {
echo "Usage: master.sh {start|stop|restart}" >&2
echo "Usage: master.sh {status|start|stop|restart}" >&2
echo " status: the status of master server"
echo " start: start the master server"
echo " stop: stop the master server"
echo " restart: restart the master server"
Expand All @@ -120,6 +131,9 @@ function help() {
command=$1
shift 1
case $command in
status)
status_server $@;
;;
start)
start_server $@;
;;
Expand Down
17 changes: 16 additions & 1 deletion bin/tubemq
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ function start_server() {
popd
}

# status of the specified service
function status_server() {
if running; then
echo "TubeMQ $SERVICE is running."
exit 0
else
echo "TubeMQ $SERVICE is not running."
exit 1
fi
}

# stop the specified service
function stop_server() {
if ! running; then
Expand All @@ -111,7 +122,8 @@ function stop_server() {

# display usage
function help() {
echo "Usage: tubemq {master|broker} {start|stop|restart}" >&2
echo "Usage: tubemq {master|broker} {status|start|stop|restart}" >&2
echo " status: start the master/broker server"
echo " start: start the master/broker server"
echo " stop: stop the master/broker server"
echo " restart: restart the master/broker server"
Expand Down Expand Up @@ -146,6 +158,9 @@ LOG_FILE="$LOG_DIR/$SERVICE.log"
PID_FILE="$PID_DIR/.$SERVICE.run.pid"

case $COMMAND in
status)
status_server $@;
;;
start)
start_server $@;
;;
Expand Down

0 comments on commit 734d6af

Please sign in to comment.