forked from eljefe6a/kafkainitd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kafka-server
executable file
·94 lines (86 loc) · 2.61 KB
/
kafka-server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Starts a Kafka Broker
#
# chkconfig: 35 85 15
# description: Kafka Broker
#
### BEGIN INIT INFO
# Provides: kafka
# Required-Start: $local_fs $remote_fs $network $syslog zookeeper
# Required-Stop: $local_fs $remote_fs $network $syslog zookeeper
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Startup script for Kafka broker
# Description: Kafka is a high-throughput distributed messaging system.
### END INIT INFO
DAEMON_PATH=/usr/bin
DAEMON_NAME=kafka
PIDFILE=/var/run/kafka-broker.pid
PATH=$PATH:$DAEMON_PATH
PROPERTIES_FILE=/etc/kafka/server.properties
START_SCRIPT=kafka-server-start
STOP_SCRIPT=kafka-server-stop
NAME="Kafka Broker"
LOG_FILE=/var/log/kafka/kafka-server.out
case "$1" in
start)
echo "Starting $DAEMON_NAME";
PID=`$DAEMON_PATH/$START_SCRIPT $PROPERTIES_FILE > $LOG_FILE 2>&1 & echo $!`
if [ -z $PID ]; then
printf "%s\n" "$NAME failed to start"
else
echo $PID > $PIDFILE
printf "%s\n" "$NAME started"
fi
;;
status)
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
printf "%s\n" "$NAME process dead but pidfile exists"
else
echo "$NAME running"
fi
else
printf "%s\n" "$NAME service not running"
fi
;;
stop)
printf "%-50s" "Stopping $NAME"
PID=`cat $PIDFILE`
cd $DAEMON_PATH
if [ -f $PIDFILE ]; then
$DAEMON_PATH/$STOP_SCRIPT 2>/dev/null
kill -HUP $PID
printf "%s\n" "$NAME stopped"
rm -f $PIDFILE
else
printf "%s\n" "$NAME pidfile not found"
fi
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac
exit 0