Skip to content

Instantly share code, notes, and snippets.

@nicholasserra
Forked from superscott/kafka
Created March 29, 2017 20:10
Show Gist options
  • Save nicholasserra/f406bacedbf6b075cab017b8bcccb2d6 to your computer and use it in GitHub Desktop.
Save nicholasserra/f406bacedbf6b075cab017b8bcccb2d6 to your computer and use it in GitHub Desktop.
Simple Kafka Ubuntu init.d Startup Script
DAEMON_PATH=/opt/kafka/bin
DAEMON_NAME=kafka
# Check that networking is up.
#[ ${NETWORKING} = "no" ] && exit 0
PATH=$PATH:$DAEMON_PATH
# See how we were called.
case "$1" in
start)
# Start daemon.
echo "Starting $DAEMON_NAME";
nohup $DAEMON_PATH/kafka-server-start.sh -daemon /opt/kafka/config/server.properties
;;
stop)
# Stop daemons.
echo "Shutting down $DAEMON_NAME";
pid=`ps ax | grep -i 'kafka.Kafka' | grep -v grep | awk '{print $1}'`
if [ -n "$pid" ]
then
kill -9 $pid
else
echo "Kafka was not Running"
fi
;;
restart)
$0 stop
sleep 2
$0 start
;;
status)
pid=`ps ax | grep -i 'kafka.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