Files
errors.bitreport.pt/ingest-api/src/server.ts
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

29 lines
690 B
TypeScript

import mysql from "mysql2/promise";
import { loadEnv } from "./config/env.js";
import { buildApp } from "./buildApp.js";
const _env = loadEnv();
const _pool = mysql.createPool({
uri: _env.DATABASE_URL,
connectionLimit: 16,
waitForConnections: true,
enableKeepAlive: true,
});
const _app = await buildApp({ env: _env, pool: _pool });
const _close = async () => {
await _app.close();
await _pool.end();
};
process.on("SIGINT", () => {
void _close().then(() => process.exit(0));
});
process.on("SIGTERM", () => {
void _close().then(() => process.exit(0));
});
await _app.listen({ port: _env.PORT, host: "0.0.0.0" });
_app.log.info(`ingest-api listening on ${_env.PORT}`);