-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathkafka
executable file
·99 lines (88 loc) · 1.72 KB
/
kafka
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
95
96
97
98
99
#!/bin/sh
#
# kafka-manager This shell script takes care of starting and stopping
# the kafka
#
# chkconfig: - 64 36
# description: kafka
# processname: kafka-manager
# config: /opt/kafka_2.10-0.8.2.1/conf/application.conf
### BEGIN INIT INFO
# Provides: kafka
# Required-Start: $local_fs $remote_fs $network $named $syslog $time
# Required-Stop: $local_fs $remote_fs $network $named $syslog $time
# Short-Description: start and stop kafka-manager
# Description: kafka
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
dirkafka="/opt/kafka"
pidckeck(){
pid=`ps ax | grep kafkaServer | grep -v grep | grep java| awk '{print $1}'`
}
start(){
pidckeck
if [ -z "$pid" ]; then
echo "Starting kafka"
sh $dirkafka/bin/kafka-server-start.sh $dirkafka/config/server.properties > /dev/null 2>&1 &
sleep 3
pidckeck
if [ -z "$pid" ]; then
echo "Fail Start kafka"
echo "Read logs for detail"
else
echo "kafka has started"
fi
else
echo "kafka is already running"
echo "PID $pid"
fi
}
stop(){
pidckeck
if [ -z "$pid" ]; then
echo "kafka isn't running"
else
sh $dirkafka/bin/kafka-server-stop.sh
sleep 3
pidckeck
if [ -z "$pid" ]; then
echo "kafka-manager has stopped"
else
echo "[WARNING] kafka-manager hasn't stoped"
fi
fi
}
restart(){
stop
start
}
status(){
pidckeck
if [ -z "$pid" ]; then
echo "kafka isn't running"
else
echo "kafka is already running"
echo "PID $pid"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
exit $?