feat: add privacy-safe server diagnostics
This commit is contained in:
1 parent
2360506607
commit
a3963ad0f6
27 files changed
+1305
-112
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { loadConfig } from './config.js';
|
||||
import { closePool, withTransaction } from './db.js';
|
||||
import { writeEmergencyDiagnostic } from './diagnostics.js';
|
||||
|
||||
export async function runRetention(): Promise<{ deletedTasks: number; deletedAuditEvents: number; deletedSessions: number }> {
|
||||
const config = loadConfig();
|
||||
@@ -34,9 +35,16 @@ export async function runRetention(): Promise<{ deletedTasks: number; deletedAud
|
||||
|
||||
if (process.argv[1]?.endsWith('/retention.ts') || process.argv[1]?.endsWith('/retention.js')) {
|
||||
runRetention()
|
||||
.then((result) => console.log(JSON.stringify({ ok: true, ...result })))
|
||||
.then((result) => console.log(JSON.stringify({
|
||||
ok: true,
|
||||
diagnostic_event: 'retention.completed',
|
||||
diagnostic_stage: 'data_retention',
|
||||
...result
|
||||
})))
|
||||
.catch((error) => {
|
||||
console.error(JSON.stringify({ ok: false, error: error.message || String(error) }));
|
||||
writeEmergencyDiagnostic('retention.failed', error, {
|
||||
diagnostic_stage: 'data_retention'
|
||||
});
|
||||
process.exitCode = 1;
|
||||
})
|
||||
.finally(() => closePool());
|
||||
|
||||
Reference in new issue
Block a user