#!/usr/bin/env bash # Start a real Apache Pulsar broker with no Docker and no root. # # The standalone distribution bundles ZooKeeper, BookKeeper and the broker in one process, which # is why a single tarball is enough. -nss skips the stream storage (BookKeeper's table service, # needed only by stateful Pulsar Functions) and -nfw skips the functions worker; both save # several hundred megabytes of heap and a few seconds of startup. # # PULSAR_HOME must point at an unpacked apache-pulsar--bin directory. Pulsar 4.2 # supports Java 17 and 21; the transcripts here were produced on Temurin 21. set -eu : "${PULSAR_HOME:?set PULSAR_HOME to an unpacked apache-pulsar-*-bin directory}" export PULSAR_MEM="${PULSAR_MEM:--Xms384m -Xmx700m -XX:MaxDirectMemorySize=384m}" cd "$PULSAR_HOME" setsid nohup bin/pulsar standalone -nss -nfw > /tmp/pulsar-start.log 2>&1 < /dev/null & for _ in $(seq 1 90); do if [ "$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8080/admin/v2/brokers/version)" = "200" ]; then echo "broker ready on 6650 (admin 8080), version $(curl -s http://127.0.0.1:8080/admin/v2/brokers/version)" exit 0 fi sleep 2 done echo "broker did not start; see /tmp/pulsar-start.log" >&2 exit 1