#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" RUN_DIR="$ROOT_DIR/.run" stop_one() { local name="$1" local pid_file="$2" if [[ ! -f "$pid_file" ]]; then echo "$name is not running" return 0 fi local pid pid="$(cat "$pid_file")" if [[ -n "$pid" ]] && kill -0 "$pid" >/dev/null 2>&1; then kill "$pid" echo "Stopped $name (PID $pid)" else echo "$name pid file was stale" fi rm -f "$pid_file" } stop_one "backend" "$RUN_DIR/backend.pid" stop_one "frontend" "$RUN_DIR/frontend.pid"