Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JXVi2GMQ7bR5EmbUFdDj7N
28 lines
2.0 KiB
Bash
Executable File
28 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Starts the whole demo stack without Docker, all on 127.0.0.1:
|
|
# fake OpenAI server :8099 -> the Spring app :8080 <-scraped every 2s- Prometheus :9090 <- Grafana :3000
|
|
# PROM and GRAFANA default to where the article says to unpack the release tarballs.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
PROM="${PROM:-/tmp/tools/obs/prom}"; GRAFANA="${GRAFANA:-/tmp/tools/obs/grafana}"
|
|
RUN=/tmp/obs-run; rm -rf "$RUN"; mkdir -p "$RUN/dashboards" "$RUN/prom" "$RUN/grafana/data" "$RUN/grafana/logs" "$RUN/grafana/plugins"
|
|
cp dashboards/*.json "$RUN/dashboards/"
|
|
mvn -q -B -DskipTests package
|
|
JAR=$(ls target/*.jar | grep -v original | head -1)
|
|
start() { local name=$1; shift; setsid nohup "$@" > "$RUN/$name.log" 2>&1 < /dev/null & echo $! > "$RUN/$name.pid"; }
|
|
wait_for() { for i in $(seq 1 60); do curl -s -o /dev/null "$1" && return 0; sleep 1; done; echo "timeout waiting for $1" >&2; exit 1; }
|
|
|
|
# the fake server ships inside the same Boot jar; PropertiesLauncher lets us pick its main class
|
|
start fake java -Dloader.main=com.ankurm.observability.fake.FakeOpenAiServer -cp "$JAR" org.springframework.boot.loader.launch.PropertiesLauncher 8099
|
|
wait_for http://127.0.0.1:8099/
|
|
start app java -jar "$JAR" --spring.profiles.active=stack
|
|
wait_for http://127.0.0.1:8080/actuator/health
|
|
start prometheus "$PROM/prometheus" --config.file=stack/prometheus.yml --storage.tsdb.path="$RUN/prom" --web.listen-address=127.0.0.1:9090
|
|
wait_for http://127.0.0.1:9090/-/ready
|
|
GF_PATHS_DATA="$RUN/grafana/data" GF_PATHS_LOGS="$RUN/grafana/logs" GF_PATHS_PLUGINS="$RUN/grafana/plugins" \
|
|
GF_PATHS_PROVISIONING="$PWD/stack/grafana/provisioning" GF_SERVER_HTTP_ADDR=127.0.0.1 GF_SERVER_HTTP_PORT=3000 \
|
|
GF_SECURITY_ADMIN_PASSWORD=admin GF_ANALYTICS_REPORTING_ENABLED=false GF_ANALYTICS_CHECK_FOR_UPDATES=false \
|
|
start grafana "$GRAFANA/bin/grafana" server --homepath "$GRAFANA"
|
|
wait_for http://127.0.0.1:3000/api/health
|
|
echo "up: app :8080, prometheus :9090, grafana :3000 (admin/admin). pids in $RUN/*.pid"
|