aboutsummaryrefslogtreecommitdiff
path: root/system/kafka/rc.kafka
blob: 12d74bc8b73945bba31fc01634c294cd8bbad06a (plain)
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
#!/bin/sh
# Start/stop/restart Apache Zookeeper daemon

SERVER_CONFIG=(server.properties)

USER=kafka
kafka_start(){
  for conf in ${SERVER_CONFIG[@]}; do
    sudo -u ${USER} sh -c "/usr/bin/kafka-server-start.sh -daemon /etc/kafka/${conf}"
  done
}

kafka_stop() {
  sudo -u ${USER} sh -c "/usr/bin/kafka-server-stop.sh"
}

kafka_restart() {
  kafka_start
  sleep 1
  kafka_stop
}

print_usage() {
  echo "usage $0 start|stop|restart"
}

case "$1" in
  'start')
    kafka_start
    ;;
  'stop')
    kafka_stop
    ;;
  'restart')
    kafka_restart
    ;;
  *)
    print_usage
    ;;
esac