#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")/.." PID_FILE=/tmp/kraiken-watcher.pid PROJECT_NAME=${COMPOSE_PROJECT_NAME:-$(basename "$PWD")} start_stack() { if [[ -f "$PID_FILE" ]]; then local existing_pid existing_pid=$(cat "$PID_FILE") if kill -0 "$existing_pid" 2>/dev/null; then echo "Stopping existing kraiken-lib watcher ($existing_pid)..." kill "$existing_pid" 2>/dev/null || true wait "$existing_pid" 2>/dev/null || true fi rm -f "$PID_FILE" fi # Show branch if set if [[ -n "${GIT_BRANCH:-}" ]]; then echo "Branch: $GIT_BRANCH" fi echo "Building kraiken-lib..." ./scripts/build-kraiken-lib.sh echo "Starting stack..." podman-compose up -d echo "Watching for kraiken-lib changes..." ./scripts/watch-kraiken-lib.sh & echo $! > "$PID_FILE" echo "" echo "[ok] Stack started" echo " Web App: http://localhost:8081/app/" echo " GraphQL: http://localhost:8081/graphql" } stop_stack() { if [[ -f "$PID_FILE" ]]; then local watcher_pid watcher_pid=$(cat "$PID_FILE") if kill "$watcher_pid" 2>/dev/null; then wait "$watcher_pid" 2>/dev/null || true fi rm -f "$PID_FILE" fi podman-compose down echo "[ok] Stack stopped" } check_health() { echo "Checking health..." local services=(anvil postgres ponder webapp landing txn-bot caddy) for service in "${services[@]}"; do local container container=$(podman ps --all \ --filter "label=com.docker.compose.project=${PROJECT_NAME}" \ --filter "label=com.docker.compose.service=${service}" \ --format '{{.Names}}' | head -n1) if [[ -z "$container" ]]; then echo " [??] $service (not created)" continue fi if podman healthcheck run "$container" &>/dev/null; then echo " [ok] $service" else echo " [!!] $service" fi done } usage() { cat <