Page MenuHomeSoftware Heritage

init.erb
No OneTemporary

init.erb

#!/bin/sh
NAME=kafka
PID_FILE=/var/run/$NAME.pid
DAEMON="/opt/kafka/bin/kafka-server-start.sh"
DAEMON_OPTS="/opt/kafka/config/server.properties"
start() {
if [ -f $PID_FILE ]
then
PID=`cat $PID_FILE`
if [ -z "`ps -ef | awk '{print $2}' | grep "^$PID$"`" ]; then
echo "\n$PID_FILE exists, process is already running"
exit 0
else
echo "\n$PID_FILE exists but the process is not running. Deleting $PID_FILE and re-trying"
rm -f $PID_FILE
start
fi
else
exec $DAEMON $DAEMON_OPTS >> /var/log/kafka/server.log 2>&1 &
sleep 2
PID=`ps ax | grep -E '[k]afka.Kafka' | awk '{print $1}'`
echo $PID > $PID_FILE;
fi
}
stop() {
if [ ! -f $PID_FILE ]
then
echo "\n$PID_FILE does not exist, process is not running"
exit 1
else
kill `cat $PID_FILE`;
rm -f $PID_FILE;
echo "\n$NAME stopped"
exit 0
fi
}
status() {
if [ -f $PID_FILE ]
then
PID=`cat $PID_FILE`
if [ -z "`ps -ef | awk '{print $2}' | grep "^$PID$"`" ]
then
echo "$NAME stopped but pid file exists"
exit 1
else
echo "$NAME running with pid $PID"
exit 0
fi
else
echo "$NAME stopped"
exit 1
fi
}
case "$1" in
status)
status
;;
start)
echo -n "Starting daemon: "$NAME
start
;;
stop)
echo -n "Stopping daemon: "$NAME
stop
;;
restart)
echo -n "Restarting daemon: "$NAME
stop
start
;;
*)
echo "Usage: "$1" {status|start|stop|restart}"
exit 1
esac
exit 0

File Metadata

Mime Type
text/x-shellscript
Expires
Jun 4 2025, 6:48 PM (12 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3398788

Event Timeline