Skip to content

Instantly share code, notes, and snippets.

@renexu
Forked from superscott/kafka
Last active September 21, 2016 05:21
Show Gist options
  • Select an option

  • Save renexu/1ecee749400aeca31c28d4daaef797e3 to your computer and use it in GitHub Desktop.

Select an option

Save renexu/1ecee749400aeca31c28d4daaef797e3 to your computer and use it in GitHub Desktop.

Revisions

  1. renexu revised this gist Sep 21, 2016. 1 changed file with 17 additions and 4 deletions.
    21 changes: 17 additions & 4 deletions kafka
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,29 @@
    DAEMON_PATH=/opt/kafka/bin
    #! /bin/sh

    ### BEGIN INIT INFO
    # Provides: kafka
    # Required-Start: $remote_fs
    # Required-Stop: $remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: A high-throughput distributed messaging system.
    # Description: Kafka is a distributed, partitioned, replicated commit log service.
    # It provides the functionality of a messaging system, but with a unique design.
    ### END INIT INFO

    KAFKA_HOME=/home/ubuntu/kafka
    DAEMON_NAME=kafka
    # Check that networking is up.
    #[ ${NETWORKING} = "no" ] && exit 0

    PATH=$PATH:$DAEMON_PATH
    #PATH=$PATH:$KAFKA_HOME

    # 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
    nohup $KAFKA_HOME/bin/kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties
    ;;
    stop)
    # Stop daemons.
    @@ -42,4 +55,4 @@ case "$1" in
    exit 1
    esac

    exit 0
    exit 0
  2. @superscott superscott created this gist Sep 12, 2014.
    45 changes: 45 additions & 0 deletions kafka
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    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