nicoloboschi commented on code in PR #3649:
URL: https://github.com/apache/bookkeeper/pull/3649#discussion_r1023638622
##########
bin/bookkeeper-daemon.sh:
##########
@@ -108,74 +108,101 @@ rotate_out_log ()
mkdir -p "$BOOKIE_LOG_DIR"
-case $startStop in
- (start)
- if [ -f $pid_file ]; then
- PREVIOUS_PID=$(cat $pid_file)
- if kill -0 $PREVIOUS_PID > /dev/null 2>&1; then
- echo $command running as process $PREVIOUS_PID. Stop it first.
+start()
+{
+ if [ -f $pid_file ]; then
+ PREVIOUS_PID=$(cat $pid_file)
+ if kill -0 $PREVIOUS_PID > /dev/null 2>&1; then
+ echo $command running as process $PREVIOUS_PID. Stop it first.
+ exit 1
+ fi
+ fi
+
+ rotate_out_log $out
+ echo starting $command, logging to $logfile
+ bookkeeper=$BK_HOME/bin/bookkeeper
+ nohup $bookkeeper $command "$@" > "$out" 2>&1 < /dev/null &
+ echo $! > $pid_file
+ sleep 1; head $out
+ sleep 2;
+ if ! kill -0 $! > /dev/null ; then
exit 1
fi
- fi
-
- rotate_out_log $out
- echo starting $command, logging to $logfile
- bookkeeper=$BK_HOME/bin/bookkeeper
- nohup $bookkeeper $command "$@" > "$out" 2>&1 < /dev/null &
- echo $! > $pid_file
- sleep 1; head $out
- sleep 2;
- if ! kill -0 $! > /dev/null ; then
- exit 1
- fi
- ;;
+}
- (stop)
- if [ -f $pid_file ]; then
- TARGET_PID=$(cat $pid_file)
- if kill -0 $TARGET_PID > /dev/null 2>&1; then
- echo stopping $command
- kill $TARGET_PID
-
- count=0
- location=$BOOKIE_LOG_DIR
- while kill -0 $TARGET_PID > /dev/null 2>&1;
- do
- echo "Shutdown is in progress... Please wait..."
- sleep 1
- count=$(expr $count + 1)
-
- if [ "$count" = "$BOOKIE_STOP_TIMEOUT" ]; then
- break
+stop()
+{
+ if [ -f $pid_file ]; then
+ TARGET_PID=$(cat $pid_file)
+ if kill -0 $TARGET_PID > /dev/null 2>&1; then
+ echo stopping $command
+ kill $TARGET_PID
+
+ count=0
+ location=$BOOKIE_LOG_DIR
+ while kill -0 $TARGET_PID > /dev/null 2>&1;
+ do
+ echo "Shutdown is in progress... Please wait..."
+ sleep 1
+ count=$(expr $count + 1)
+
+ if [ "$count" = "$BOOKIE_STOP_TIMEOUT" ]; then
+ break
+ fi
+ done
+
+ if [ "$count" != "$BOOKIE_STOP_TIMEOUT" ]; then
+ echo "Shutdown completed."
fi
- done
-
- if [ "$count" != "$BOOKIE_STOP_TIMEOUT" ]; then
- echo "Shutdown completed."
- fi
- if kill -0 $TARGET_PID > /dev/null 2>&1; then
- fileName=$location/$command.out
- $JAVA_HOME/bin/jstack $TARGET_PID > $fileName
- echo Thread dumps are taken for analysis at $fileName
- if [ "$1" == "-force" ]
- then
- echo forcefully stopping $command
- kill -9 $TARGET_PID >/dev/null 2>&1
- echo Successfully stopped the process
- else
- echo "WARNNING : Bookie Server is not stopped completely."
- exit 1
+ if kill -0 $TARGET_PID > /dev/null 2>&1; then
+ fileName=$location/$command.out
+ $JAVA_HOME/bin/jstack $TARGET_PID > $fileName
+ echo Thread dumps are taken for analysis at $fileName
+ if [ "$1" == "-force" ]
+ then
+ echo forcefully stopping $command
+ kill -9 $TARGET_PID >/dev/null 2>&1
+ echo Successfully stopped the process
+ else
+ echo "WARNNING : Bookie Server is not stopped completely."
+ exit 1
+ fi
fi
+ else
+ echo no $command to stop
fi
+ rm $pid_file
else
echo no $command to stop
fi
- rm $pid_file
- else
- echo no $command to stop
- fi
+}
+case $startStop in
+ (start)
+ start "$*"
+ ;;
+
+ (stop)
+ stop $1
;;
+ (restart)
+ forceStopFlag=$(echo "$*"|grep "\-force")
+ if [[ "$forceStopFlag" != "" ]]
+ then
+ stop "-force"
+ else
+ stop
+ fi
+ if [ "$?" == 0 ]
+ then
+ sleep 3
+ paramaters="$*"
Review Comment:
typo: parameters
##########
bin/bookkeeper-daemon.sh:
##########
@@ -108,74 +108,101 @@ rotate_out_log ()
mkdir -p "$BOOKIE_LOG_DIR"
-case $startStop in
- (start)
- if [ -f $pid_file ]; then
- PREVIOUS_PID=$(cat $pid_file)
- if kill -0 $PREVIOUS_PID > /dev/null 2>&1; then
- echo $command running as process $PREVIOUS_PID. Stop it first.
+start()
+{
+ if [ -f $pid_file ]; then
+ PREVIOUS_PID=$(cat $pid_file)
+ if kill -0 $PREVIOUS_PID > /dev/null 2>&1; then
+ echo $command running as process $PREVIOUS_PID. Stop it first.
+ exit 1
+ fi
+ fi
+
+ rotate_out_log $out
+ echo starting $command, logging to $logfile
+ bookkeeper=$BK_HOME/bin/bookkeeper
+ nohup $bookkeeper $command "$@" > "$out" 2>&1 < /dev/null &
+ echo $! > $pid_file
+ sleep 1; head $out
+ sleep 2;
+ if ! kill -0 $! > /dev/null ; then
exit 1
fi
- fi
-
- rotate_out_log $out
- echo starting $command, logging to $logfile
- bookkeeper=$BK_HOME/bin/bookkeeper
- nohup $bookkeeper $command "$@" > "$out" 2>&1 < /dev/null &
- echo $! > $pid_file
- sleep 1; head $out
- sleep 2;
- if ! kill -0 $! > /dev/null ; then
- exit 1
- fi
- ;;
+}
- (stop)
- if [ -f $pid_file ]; then
- TARGET_PID=$(cat $pid_file)
- if kill -0 $TARGET_PID > /dev/null 2>&1; then
- echo stopping $command
- kill $TARGET_PID
-
- count=0
- location=$BOOKIE_LOG_DIR
- while kill -0 $TARGET_PID > /dev/null 2>&1;
- do
- echo "Shutdown is in progress... Please wait..."
- sleep 1
- count=$(expr $count + 1)
-
- if [ "$count" = "$BOOKIE_STOP_TIMEOUT" ]; then
- break
+stop()
+{
+ if [ -f $pid_file ]; then
+ TARGET_PID=$(cat $pid_file)
+ if kill -0 $TARGET_PID > /dev/null 2>&1; then
+ echo stopping $command
+ kill $TARGET_PID
+
+ count=0
+ location=$BOOKIE_LOG_DIR
+ while kill -0 $TARGET_PID > /dev/null 2>&1;
+ do
+ echo "Shutdown is in progress... Please wait..."
+ sleep 1
+ count=$(expr $count + 1)
+
+ if [ "$count" = "$BOOKIE_STOP_TIMEOUT" ]; then
+ break
+ fi
+ done
+
+ if [ "$count" != "$BOOKIE_STOP_TIMEOUT" ]; then
+ echo "Shutdown completed."
fi
- done
-
- if [ "$count" != "$BOOKIE_STOP_TIMEOUT" ]; then
- echo "Shutdown completed."
- fi
- if kill -0 $TARGET_PID > /dev/null 2>&1; then
- fileName=$location/$command.out
- $JAVA_HOME/bin/jstack $TARGET_PID > $fileName
- echo Thread dumps are taken for analysis at $fileName
- if [ "$1" == "-force" ]
- then
- echo forcefully stopping $command
- kill -9 $TARGET_PID >/dev/null 2>&1
- echo Successfully stopped the process
- else
- echo "WARNNING : Bookie Server is not stopped completely."
- exit 1
+ if kill -0 $TARGET_PID > /dev/null 2>&1; then
+ fileName=$location/$command.out
+ $JAVA_HOME/bin/jstack $TARGET_PID > $fileName
+ echo Thread dumps are taken for analysis at $fileName
+ if [ "$1" == "-force" ]
+ then
+ echo forcefully stopping $command
+ kill -9 $TARGET_PID >/dev/null 2>&1
+ echo Successfully stopped the process
+ else
+ echo "WARNNING : Bookie Server is not stopped completely."
+ exit 1
+ fi
fi
+ else
+ echo no $command to stop
fi
+ rm $pid_file
else
echo no $command to stop
fi
- rm $pid_file
- else
- echo no $command to stop
- fi
+}
+case $startStop in
+ (start)
+ start "$*"
+ ;;
+
+ (stop)
+ stop $1
;;
+ (restart)
+ forceStopFlag=$(echo "$*"|grep "\-force")
+ if [[ "$forceStopFlag" != "" ]]
+ then
+ stop "-force"
+ else
+ stop
+ fi
+ if [ "$?" == 0 ]
+ then
+ sleep 3
+ paramaters="$*"
+ startParamaters=${paramaters//-force/}
+ start "$startParamaters"
+ else
+ echo "WARNNING : $command failed restart, for $command is not
stopped completely."
Review Comment:
```suggestion
echo "WARNING : $command restart failed, $command is not stopped
completely."
```
##########
bin/bookkeeper-daemon.sh:
##########
@@ -108,74 +108,101 @@ rotate_out_log ()
mkdir -p "$BOOKIE_LOG_DIR"
-case $startStop in
- (start)
- if [ -f $pid_file ]; then
- PREVIOUS_PID=$(cat $pid_file)
- if kill -0 $PREVIOUS_PID > /dev/null 2>&1; then
- echo $command running as process $PREVIOUS_PID. Stop it first.
+start()
+{
+ if [ -f $pid_file ]; then
+ PREVIOUS_PID=$(cat $pid_file)
+ if kill -0 $PREVIOUS_PID > /dev/null 2>&1; then
+ echo $command running as process $PREVIOUS_PID. Stop it first.
+ exit 1
+ fi
+ fi
+
+ rotate_out_log $out
+ echo starting $command, logging to $logfile
+ bookkeeper=$BK_HOME/bin/bookkeeper
+ nohup $bookkeeper $command "$@" > "$out" 2>&1 < /dev/null &
+ echo $! > $pid_file
+ sleep 1; head $out
+ sleep 2;
+ if ! kill -0 $! > /dev/null ; then
exit 1
fi
- fi
-
- rotate_out_log $out
- echo starting $command, logging to $logfile
- bookkeeper=$BK_HOME/bin/bookkeeper
- nohup $bookkeeper $command "$@" > "$out" 2>&1 < /dev/null &
- echo $! > $pid_file
- sleep 1; head $out
- sleep 2;
- if ! kill -0 $! > /dev/null ; then
- exit 1
- fi
- ;;
+}
- (stop)
- if [ -f $pid_file ]; then
- TARGET_PID=$(cat $pid_file)
- if kill -0 $TARGET_PID > /dev/null 2>&1; then
- echo stopping $command
- kill $TARGET_PID
-
- count=0
- location=$BOOKIE_LOG_DIR
- while kill -0 $TARGET_PID > /dev/null 2>&1;
- do
- echo "Shutdown is in progress... Please wait..."
- sleep 1
- count=$(expr $count + 1)
-
- if [ "$count" = "$BOOKIE_STOP_TIMEOUT" ]; then
- break
+stop()
+{
+ if [ -f $pid_file ]; then
+ TARGET_PID=$(cat $pid_file)
+ if kill -0 $TARGET_PID > /dev/null 2>&1; then
+ echo stopping $command
+ kill $TARGET_PID
+
+ count=0
+ location=$BOOKIE_LOG_DIR
+ while kill -0 $TARGET_PID > /dev/null 2>&1;
+ do
+ echo "Shutdown is in progress... Please wait..."
+ sleep 1
+ count=$(expr $count + 1)
+
+ if [ "$count" = "$BOOKIE_STOP_TIMEOUT" ]; then
+ break
+ fi
+ done
+
+ if [ "$count" != "$BOOKIE_STOP_TIMEOUT" ]; then
+ echo "Shutdown completed."
fi
- done
-
- if [ "$count" != "$BOOKIE_STOP_TIMEOUT" ]; then
- echo "Shutdown completed."
- fi
- if kill -0 $TARGET_PID > /dev/null 2>&1; then
- fileName=$location/$command.out
- $JAVA_HOME/bin/jstack $TARGET_PID > $fileName
- echo Thread dumps are taken for analysis at $fileName
- if [ "$1" == "-force" ]
- then
- echo forcefully stopping $command
- kill -9 $TARGET_PID >/dev/null 2>&1
- echo Successfully stopped the process
- else
- echo "WARNNING : Bookie Server is not stopped completely."
- exit 1
+ if kill -0 $TARGET_PID > /dev/null 2>&1; then
+ fileName=$location/$command.out
+ $JAVA_HOME/bin/jstack $TARGET_PID > $fileName
+ echo Thread dumps are taken for analysis at $fileName
+ if [ "$1" == "-force" ]
+ then
+ echo forcefully stopping $command
+ kill -9 $TARGET_PID >/dev/null 2>&1
+ echo Successfully stopped the process
+ else
+ echo "WARNNING : Bookie Server is not stopped completely."
+ exit 1
+ fi
fi
+ else
+ echo no $command to stop
fi
+ rm $pid_file
else
echo no $command to stop
fi
- rm $pid_file
- else
- echo no $command to stop
- fi
+}
+case $startStop in
+ (start)
+ start "$*"
+ ;;
+
+ (stop)
+ stop $1
;;
+ (restart)
+ forceStopFlag=$(echo "$*"|grep "\-force")
+ if [[ "$forceStopFlag" != "" ]]
+ then
+ stop "-force"
+ else
+ stop
+ fi
+ if [ "$?" == 0 ]
+ then
+ sleep 3
+ paramaters="$*"
+ startParamaters=${paramaters//-force/}
Review Comment:
just a nit: if one of the command we have to start here accepts a flag like
`-force-xxx` it will be blanked as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]