Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TUBEMQ-240] add status command for broker/master script #167

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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