#!/usr/bin/env bash # Starts the resource server on :8081 with the given profiles, replacing any previous instance. # Usage: ./scripts/run-rs.sh stub,roles,audience set -eu PROFILES="${1:-stub}" cd "$(dirname "$0")/.." for p in $(ps -eo pid,cmd | grep '[R]esourceServerApplication' | awk '{print $1}'); do kill -9 "$p" || true; done sleep 1 setsid nohup mvn -B -o org.springframework.boot:spring-boot-maven-plugin:run \ -Dspring-boot.run.main-class=com.ankurm.rsdemo.ResourceServerApplication \ -Dspring-boot.run.profiles="$PROFILES" > "/tmp/rs-${PROFILES//,/-}.log" 2>&1 < /dev/null & for i in $(seq 1 60); do curl -sf http://localhost:8081/api/public/ping -o /dev/null 2>/dev/null && { echo "resource server up on :8081 with profiles: $PROFILES"; exit 0; } sleep 2 done echo "resource server failed to start; see /tmp/rs-${PROFILES//,/-}.log" >&2; exit 1