Created
July 8, 2016 05:49
-
-
Save rmzamora/7699535b3665fcb3bac226f3c2a96d68 to your computer and use it in GitHub Desktop.
zookeeper start/stop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: confluent-zookepper | |
# Required-Start: $remote_fs | |
# Required-Stop: $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: a distributed commit log. | |
# Description: Apache Kafka is publish-subscribe messaging rethought | |
# as a distributed commit log. | |
### END INIT INFO | |
ZOOKEEPER_HOME=YOUR_KAFKA_PATH | |
ZOOKEEPER_LOG=YOUR_KAFKA_LOG_PATH | |
NAME=confluent-zookepper | |
# See how we were called. | |
case "$1" in | |
start) | |
# Start daemon. | |
echo "Starting $NAME"; | |
nohup $ZOOKEEPER_HOME/bin/zookeeper-server-start -daemon $ZOOKEEPER_HOME/etc/kafka/zookeeper.properties > $ZOOKEEPER_LOG/kafka.log 2>&1 & | |
;; | |
stop) | |
# Stop daemons. | |
echo "Shutting down $NAME"; | |
pid=$(ps ax | grep java | grep -i QuorumPeerMain | grep -v grep | awk '{print $1}') | |
if [ -n "$pid" ] | |
then | |
$ZOOKEEPER_HOME/bin/zookeeper-server-stop 2>&1 & | |
else | |
echo "Zookeper was not Running" | |
fi | |
;; | |
restart) | |
$0 stop | |
sleep 2 | |
$0 start | |
;; | |
status) | |
pid=$(ps ax | grep java | grep -i QuorumPeerMain | grep -v grep | awk '{print $1}') | |
if [ -n "$pid" ] | |
then | |
echo "Zookeper is Running as PID: $pid" | |
else | |
echo "Zookeper is not Running" | |
fi | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|status}" | |
exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment