forked from eljefe6a/kafkainitd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zookeeper
executable file
·93 lines (85 loc) · 2.44 KB
/
zookeeper
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
#!/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 Zookeeper server
#
# chkconfig: 35 85 15
# description: Zookeeper
#
### BEGIN INIT INFO
# Provides: zookeeper
# Short-Description: ZooKeeper Service
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Should-Start:
# Should-Stop:
### END INIT INFO
DAEMON_PATH=/usr/bin
DAEMON_NAME=zookeeper-server
PIDFILE=/var/run/zookeeper.pid
PATH=$PATH:$DAEMON_PATH
PROPERTIES_FILE=/etc/kafka/zookeeper.properties
START_SCRIPT=zookeeper-server-start
NAME="ZooKeeper"
LOG_FILE=/var/log/kafka/zookeeper.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
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