upstart script for kafka
Asked Answered
Z

1

1

I am using upstart script to do start kafka and zookeeper. My steps are: (1)The following is kafka-zk.conf (Put it in /etc/init/):

kill timeout 300

start on runlevel [2345]
stop on runlevel [06]

pre-start script
end script

script
    KAFKA_HOME=/home/My/kafka/kafka_<version>
    exec $KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties
end script

(2) Create symbol link: ln -s /lib/init/upstart-job /etc/init.d/kafka-zk

(3) Run "sudo service kafka-zk start|stop" to start or stop kafka and zookeeper

My question is: when running "sudo service kafka-zk stop", I am not sure whether the script zookeeper-server-stop.sh (http://kafka.apache.org/documentation.html#quickstart) was called or not. How to make the upstart script to use zookeeper-server-stop.sh?

Also, should I use exec $KAFKA_HOME/bin/zookeeper-server-start.sh -daemon $KAFKA_HOME/config/zookeeper.properties?

Zarf answered 17/8, 2015 at 14:34 Comment(0)
Z
1

(1) The following is zookeeper-server-stop.sh. See https://github.com/kafka-dev/kafka/blob/master/bin/zookeeper-server-stop.sh

   #!/bin/sh
    ps ax | grep -i 'zookeeper' | grep -v grep | awk '{print $1}' | xargs kill -SIGINT

(2) upstart can make the job run in background. So "-daemon" is not necessary

Zarf answered 18/8, 2015 at 15:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.