Spring Boot 4 Actuator in production: endpoints, security, custom health indicators
Companion repository for the ankurm.com article. Every transcript in docs/output/ was produced by running this project; scripts/run-all.sh regenerates all of them. Verified against Spring Boot 4.1.1 / Framework 7.0.9 / Security 7.1.1 / Micrometer 1.17.1 / kafka-clients 4.2.1 on Temurin JDK 25.0.4.1+1.
This commit is contained in:
26
scripts/run.sh
Executable file
26
scripts/run.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Start the application with the given comma-separated profiles and block until it answers.
|
||||
# ./scripts/run.sh # defaults
|
||||
# ./scripts/run.sh exposeall,open # every endpoint, no authentication
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
source scripts/env.sh
|
||||
PROFILES="${1:-}"
|
||||
LOG="${LOG:-/tmp/actuator-demo.log}"
|
||||
|
||||
scripts/stop.sh
|
||||
|
||||
ARGS=(-B -o org.springframework.boot:spring-boot-maven-plugin:run)
|
||||
[ -n "$PROFILES" ] && ARGS+=("-Dspring-boot.run.profiles=$PROFILES")
|
||||
|
||||
setsid nohup "$MVN" "${ARGS[@]}" > "$LOG" 2>&1 < /dev/null &
|
||||
|
||||
READY_URL="${READY_URL:-http://127.0.0.1:${APP_PORT}/orders/count}"
|
||||
for _ in $(seq 1 90); do
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' -u ops:ops-password "$READY_URL" || true)
|
||||
[ "$code" != "000" ] && [ -n "$code" ] && exit 0
|
||||
sleep 2
|
||||
done
|
||||
echo "application did not start; tail of $LOG:" >&2
|
||||
tail -40 "$LOG" >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user