Last active
December 24, 2017 10:58
-
-
Save asraful/0aae8b90572ea0ba3a4fff93dbb8dcbe to your computer and use it in GitHub Desktop.
zookeeper as service
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/bash | |
#/etc/init.d/zookeeper | |
DAEMON_PATH=/opt/kafka/bin | |
DAEMON_NAME=zookeeper | |
PATH=$PATH:$DAMENON_PATH | |
case "$1" in | |
start) | |
pid=`ps ax | grep -i 'org.apache.zookeeper' | grep -v grep | awk '{print $1}'` | |
if [ -n "$pid" ] | |
then | |
echo "Zookeepr is already running, PID : $pid"; | |
else | |
echo "Starting $DAEMON_NAME"; | |
$DAEMON_PATH/zookeeper-server-start.sh -daemon /opt/kafka/config/zookeeper.properties | |
fi | |
;; | |
stop) | |
echo "Shutting down $DAEMON_NAME"; | |
$DAEMON_PATH/zookeeper-server-stop.sh | |
;; | |
restart) | |
$0 stop | |
sleep 2 | |
$0 start | |
;; | |
status) | |
pid=`ps ax | grep -i 'org.apache.zookeeper' | grep -v grep | awk '{print $1}'` | |
if [-n "$pid" ] | |
then | |
echo "Zookeeper is running as PID : $pid"; | |
else | |
echo "Zookeeper 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