- infra: Bugsink 2.6.3 in docker (infra/bugsink, scripts/bugsink-up.sh), database bugsink in Peppa's Postgres, Traefik route bugsink.telecom.quest - packages/bugsink: REST API client + custom-webhook payload parsing - incidents (migration 0011): incident_settings, error_sources, incidents; ingest from webhook POST /api/hooks/bugsink/<secret> and a 2-minute poll in the watchdog - incident policy per project: notify / backlog (default) / start / ask (Telegram buttons) / triage (claude -p with the owner's token, falls back to ask) - daily task cap, environments, ignore pattern; manual "fixed" until PEP-57; REGRESSED returns the task to the backlog - web «Ошибки» section, bot buttons, MCP tools for agents and the PM, help, RULES.md - testkit: mock-bugsink, mock-triage, incidents.test.ts (one test per scenario, plus a live run against the real Bugsink with PEPPA_LIVE_BUGSINK=1) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.6 KiB
Bash
Executable File
60 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Bugsink for Peppa (PEP-58), idempotent: secrets in .env, database in Peppa's Postgres,
|
|
# container peppa-bugsink on 127.0.0.1:3180, Traefik route bugsink.telecom.quest, API token.
|
|
# Usage: scripts/bugsink-up.sh [path/to/.env] (default: <repo>/.env)
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
ENV_FILE="${1:-$ROOT/.env}"
|
|
TRAEFIK_DYNAMIC="${TRAEFIK_DYNAMIC:-/Users/timur/Dev/_Zorro/_INFRA/traefik/dynamic}"
|
|
|
|
[ -f "$ENV_FILE" ] || { echo "no $ENV_FILE"; exit 1; }
|
|
chmod 600 "$ENV_FILE"
|
|
get() { grep -E "^$1=" "$ENV_FILE" | tail -1 | cut -d= -f2- || true; }
|
|
put() { [ -n "$(get "$1")" ] || { printf '%s=%s\n' "$1" "$2" >>"$ENV_FILE"; echo "added $1 to .env"; }; }
|
|
rnd() { openssl rand -hex "$1"; }
|
|
|
|
put BUGSINK_SECRET_KEY "$(rnd 32)"
|
|
put BUGSINK_DB_PASSWORD "$(rnd 16)"
|
|
put BUGSINK_ADMIN_EMAIL "admin@telecom.quest"
|
|
put BUGSINK_ADMIN_PASSWORD "$(rnd 12)"
|
|
put BUGSINK_PUBLIC_URL "https://bugsink.telecom.quest"
|
|
put BUGSINK_URL "http://127.0.0.1:3180"
|
|
# docker exec target for alert webhooks; where the container reaches Peppa's web.
|
|
put BUGSINK_CONTAINER "peppa-bugsink"
|
|
put BUGSINK_WEBHOOK_BASE "http://host.docker.internal:3100"
|
|
|
|
PG="docker exec -i peppa-postgres psql -U peppa -v ON_ERROR_STOP=1 -tA"
|
|
if [ -z "$($PG -c "select 1 from pg_roles where rolname='bugsink'")" ]; then
|
|
$PG -c "create role bugsink login password '$(get BUGSINK_DB_PASSWORD)'" >/dev/null
|
|
echo "created role bugsink"
|
|
fi
|
|
if [ -z "$($PG -c "select 1 from pg_database where datname='bugsink'")" ]; then
|
|
$PG -c "create database bugsink owner bugsink" >/dev/null
|
|
echo "created database bugsink"
|
|
fi
|
|
|
|
docker compose --env-file "$ENV_FILE" -f "$ROOT/infra/bugsink/docker-compose.yml" up -d
|
|
for i in $(seq 1 60); do
|
|
curl -sf http://127.0.0.1:3180/health/ready >/dev/null && break
|
|
sleep 2
|
|
done
|
|
curl -sf http://127.0.0.1:3180/health/ready >/dev/null || { echo "bugsink not ready"; docker logs --tail 30 peppa-bugsink; exit 1; }
|
|
|
|
# One team for all Peppa projects (the API has no team endpoints); its id goes to .env.
|
|
if [ -z "$(get BUGSINK_TEAM_ID)" ]; then
|
|
TEAM=$(docker exec peppa-bugsink bugsink-manage shell -c "
|
|
from teams.models import Team
|
|
t = Team.objects.filter(name='Peppa').first() or Team.objects.create(name='Peppa')
|
|
print(t.id)" | tail -1)
|
|
put BUGSINK_TEAM_ID "$TEAM"
|
|
fi
|
|
if [ -z "$(get BUGSINK_TOKEN)" ]; then
|
|
put BUGSINK_TOKEN "$(docker exec peppa-bugsink bugsink-manage create_auth_token | tail -1)"
|
|
fi
|
|
|
|
if [ -d "$TRAEFIK_DYNAMIC" ]; then
|
|
cp "$ROOT/infra/traefik/bugsink.yml" "$TRAEFIK_DYNAMIC/bugsink.yml"
|
|
echo "traefik route installed: $TRAEFIK_DYNAMIC/bugsink.yml"
|
|
fi
|
|
echo "bugsink ready: $(get BUGSINK_URL) (public $(get BUGSINK_PUBLIC_URL))"
|