Skip to content

Instantly share code, notes, and snippets.

@asraful
Last active December 24, 2017 10:58
Show Gist options
  • Save asraful/0aae8b90572ea0ba3a4fff93dbb8dcbe to your computer and use it in GitHub Desktop.
Save asraful/0aae8b90572ea0ba3a4fff93dbb8dcbe to your computer and use it in GitHub Desktop.
zookeeper as service
#!/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