#!/usr/bin/env bash # Start the application with the given profiles (comma-separated, may be empty) and wait until it # answers. Any instance started by a previous run is stopped first, by PID file - never by # pattern-matching the process list, which can match (and kill) the calling shell. # ./scripts/run.sh advice # ./scripts/run.sh "" # Spring Boot defaults set -euo pipefail source "$(dirname "$0")/env.sh" "$MODULE_DIR/scripts/stop.sh" PROFILES="${1:-}" [ -f "$JAR" ] || (cd "$MODULE_DIR" && mvn -q -DskipTests package) nohup java -jar "$JAR" --server.port="$PORT" ${PROFILES:+--spring.profiles.active=$PROFILES} ${EXTRA_ARGS:-} \ > "$LOG" 2>&1 < /dev/null & echo $! > "$PIDFILE" for _ in $(seq 1 60); do if curl -s -o /dev/null "$BASE/orders/1"; then exit 0; fi if ! kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then echo "application exited - see $LOG" >&2; exit 1; fi sleep 0.5 done echo "application did not start within 30s - see $LOG" >&2; exit 1