boot_cluster.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. set -ex
  3. # Launch and wait for toxiproxy
  4. ${REPOSITORY_ROOT}/vagrant/run_toxiproxy.sh &
  5. while ! nc -q 1 localhost 2185 </dev/null; do echo "Waiting"; sleep 1; done
  6. while ! nc -q 1 localhost 9095 </dev/null; do echo "Waiting"; sleep 1; done
  7. # Launch and wait for Zookeeper
  8. KAFKA_HEAP_OPTS="-Xmx192m -Dzookeeper.admin.enableServer=false"
  9. export KAFKA_HEAP_OPTS
  10. for i in 1 2 3 4 5; do
  11. KAFKA_PORT=`expr $i + 9090`
  12. cd ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT} && bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
  13. done
  14. while ! nc -q 1 localhost 21805 </dev/null; do echo "Waiting"; sleep 1; done
  15. # Launch and wait for Kafka
  16. KAFKA_HEAP_OPTS="-Xmx320m"
  17. export KAFKA_HEAP_OPTS
  18. for i in 1 2 3 4 5; do
  19. KAFKA_PORT=`expr $i + 9090`
  20. cd ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT} && bash bin/kafka-server-start.sh -daemon config/server.properties
  21. done
  22. ps auxww | grep -i kafka
  23. N=120
  24. RC=1
  25. set +x
  26. printf "Waiting for kafka5 to become available."
  27. for _ in $(seq 1 "$N"); do
  28. if nc -z 127.0.0.1 29095 </dev/null; then
  29. RC=0
  30. break
  31. fi
  32. sleep 1
  33. done
  34. printf "\n"
  35. if [ "$RC" -gt 0 ]; then
  36. echo 'Error: kafka5 failed to startup' >&2
  37. find "${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT}" -name "server.log" -print0 | xargs -0 --no-run-if-empty tail -256
  38. exit ${RC}
  39. fi