#!/usr/bin/env bash # Start the application and block until it answers. Extra arguments are passed to the app, # so a scenario can add --demo.mail.recipients=a,b,c without a new profile. # ./scripts/run.sh # defaults # ./scripts/run.sh csvlist # a profile # ./scripts/run.sh "" --demo.x=y # no profile, one override set -euo pipefail cd "$(dirname "$0")/.." source scripts/env.sh PROFILES="${1:-}"; shift || true LOG="${LOG:-/tmp/configprops-demo.log}" PIDFILE="${PIDFILE:-target/app.pid}" scripts/stop.sh ARGS=(-jar "$JAR") [ -n "$PROFILES" ] && ARGS+=("--spring.profiles.active=$PROFILES") ARGS+=("$@") setsid nohup java "${ARGS[@]}" > "$LOG" 2>&1 < /dev/null & echo $! > "$PIDFILE" for _ in $(seq 1 60); do code=$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:${APP_PORT}/precedence" || true) [ "$code" = "200" ] && exit 0 # If the JVM died -- most often because the port was still held -- fail fast and loudly # instead of letting curl answer from a process started by an earlier scenario. kill -0 "$(cat "$PIDFILE")" 2>/dev/null || { echo "JVM exited during startup:" >&2 tail -25 "$LOG" >&2; exit 1; } sleep 1 done echo "application did not answer; tail of $LOG:" >&2 tail -40 "$LOG" >&2 exit 1