Files
errors.bitreport.pt/deploy/lxc/verify.sh
T
1sonhadorandPaperclip 4604606033 feat(errors): migrate error-reporting stack from PostgreSQL to MariaDB (BIT-255)
Replace Postgres with MariaDB 11 in docker-compose; convert all
database/error_reporting and db/migrations SQL to InnoDB-friendly syntax
(DATETIME(6), AUTO_INCREMENT, ON DUPLICATE KEY). Run admin portal DDL in the
same migrate one-shot as error_reporting.

Switch ingest-api, collector-worker, and api from pg to mysql2 (pools,
parameterized queries, transactions). Align ingest writes with
er_incident_occurrences and include project_id on idempotency inserts.

Add scripts/run-mysql-migrations.sh for host-side applies; update LXC
run-migrate/verify, deployment docs, and .env.example (mysql://, ER_MYSQL_*).

Verified: npm run build + npm test in ingest-api and collector-worker;
npm run build in api. Full docker compose not run here (no local daemon).

Co-Authored-By: Paperclip <[email protected]>
2026-03-22 19:29:11 +00:00

52 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Smoke checks after install: MariaDB reachability (optional) + ingest /health.
set -euo pipefail
_ENV_FILE="/etc/error-reporting/env"
if [[ -f "${_ENV_FILE}" ]]; then
set -a
# shellcheck disable=SC1090
source "${_ENV_FILE}"
set +a
fi
_INGEST_URL="${INGEST_HEALTH_URL:-http://127.0.0.1:${PORT:-3041}/health}"
echo "verify: GET ${_INGEST_URL}"
if ! curl -sf "${_INGEST_URL}" >/dev/null; then
echo "verify: ingest /health failed" >&2
exit 1
fi
echo "verify: ingest OK"
if command -v mariadb-admin >/dev/null 2>&1 && [[ -n "${DATABASE_URL:-}" ]]; then
if [[ "${DATABASE_URL}" == mysql://* || "${DATABASE_URL}" == mariadb://* ]]; then
_PARSED="$(python3 -c "
import os
from urllib.parse import urlparse, unquote
u = urlparse(os.environ['DATABASE_URL'])
if u.scheme not in ('mysql', 'mariadb', 'mysqli'):
raise SystemExit(0)
host = u.hostname or '127.0.0.1'
port = u.port or 3306
user = unquote(u.username or '')
password = unquote(u.password or '')
print(host, port, user, password)
" 2>/dev/null)" || true
if [[ -n "${_PARSED}" ]]; then
read -r _h _p _u _pw <<< "${_PARSED}"
echo "verify: mariadb-admin ping (best-effort)"
mariadb-admin ping -h "${_h}" -P "${_p}" -u "${_u}" -p"${_pw}" --silent || true
fi
fi
fi
_ADMIN_PORT="${ADMIN_UI_PORT:-3040}"
if curl -sf "http://127.0.0.1:${_ADMIN_PORT}/" >/dev/null 2>&1; then
echo "verify: admin-ui HTTP on port ${_ADMIN_PORT} OK"
else
echo "verify: admin-ui not responding on ${_ADMIN_PORT} (expected if service stopped or demo mode off)"
fi
echo "verify: done"