Created
December 26, 2017 09:53
-
-
Save asraful/ac9b91b5780f6668817a99bc45ba601c to your computer and use it in GitHub Desktop.
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/kafka | |
DAEMON_PATH=/opt/kafka/bin | |
DAEMON_NAME=kafka | |
PATH=$PATH:$DAMENON_PATH | |
case "$1" in | |
start) | |
pid=`ps ax | grep -i 'org.apache.kafka' | grep -v grep | awk '{print $1}'` | |
if [ -n "$pid" ] | |
then | |
echo "Kafka is already running, PID : $pid"; | |
else | |
echo "Starting $DAEMON_NAME"; | |
$DAEMON_PATH/kafka-server-start.sh -daemon /opt/kafka/config/server.properties | |
fi | |
;; | |
stop) | |
echo "Shutting down $DAEMON_NAME"; | |
$DAEMON_PATH/kafka-server-stop.sh | |
;; | |
restart) | |
$0 stop | |
sleep 2 | |
$0 start | |
;; | |
status) | |
pid=`ps ax | grep -i 'org.apache.kafka' | grep -v grep | awk '{print $1}'` | |
if [ -n "$pid" ] | |
then | |
echo "Kafka is running as PID : $pid"; | |
else | |
echo "Kafka 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