health checks (#39)
resolves #35 Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/39
This commit is contained in:
parent
a29ca1a26a
commit
3ab2d9454a
14 changed files with 586 additions and 611 deletions
91
scripts/dev.sh
Executable file
91
scripts/dev.sh
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
#!/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
|
||||
|
||||
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() {
|
||||
echo "Usage: $0 {start|stop|health}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
case "${1:-help}" in
|
||||
start)
|
||||
start_stack
|
||||
;;
|
||||
stop)
|
||||
stop_stack
|
||||
;;
|
||||
health)
|
||||
check_health
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
Loading…
Add table
Add a link
Reference in a new issue