I'm trying to run kafka in supervision mode so that it can start automatically in case of a shutdown. But all the examples of running kafka use shell scripts and the supervisord
is not able to note which PID to monitor. Can anyone suggesthow to accomplish auto restart of kafka?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you are on a Unix or Linux machine, then this is when /etc/inittab comes in handy. Or you might want to use daemontools. I don't know about Windows though.
回答2:
We are running Kafka under Supervisord (http://supervisord.org/), it works like a charm. Run command looks like this (as specified in supervisord.conf
file:
command=/usr/local/bin/pidproxy /var/run/kafka.pid /usr/lib/kafka/bin/kafka-server.sh -f -p /var/run/kafka.pid
Flag -f
tells Kafka to start in foreground. If flag -p
is set, Kafka process PID is written into specified file.
The command pidproxy
is a part of Supervisord distribution. Upon receiving KILL
signal, it reads PID from specified file, and forwards the signal to the corresponding process.