-
-
Save pedro-stanaka/b442417f8ecc8f36d27cc6c17a8f6fe5 to your computer and use it in GitHub Desktop.
Simple Kafka Ubuntu init.d Startup Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created by https://www.gitignore.io/api/windows | |
### Windows ### | |
# Windows image file caches | |
Thumbs.db | |
ehthumbs.db | |
# Folder config file | |
Desktop.ini | |
# Recycle Bin used on file shares | |
$RECYCLE.BIN/ | |
# Windows Installer files | |
*.cab | |
*.msi | |
*.msm | |
*.msp | |
# Windows shortcuts | |
*.lnk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER=kafka | |
DAEMON_PATH=/opt/kafka/bin | |
KAFKA_HOME=/opt/kafka | |
DAEMON_NAME=kafka | |
USER=kafka | |
# Check that networking is up. | |
#[ ${NETWORKING} = "no" ] && exit 0 | |
start() { | |
pid=$(ps ax | grep -i 'kafka.kafka' | grep -v grep | awk '{print $1}') | |
if [[ "x$pid" -ne "x" ]]; then # Service is running | |
echo "Kafka is already running as $pid" | |
return 1 | |
fi | |
echo "Starting $DAEMON_NAME..." >&2 | |
local CMD="$DAEMON_PATH/kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties" | |
/bin/su -c "$CMD" $USER | |
echo "$DAEMON_NAME started..." | |
} | |
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 | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
;; | |
restart) | |
stop | |
sleep 2 | |
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