feat: add cleanup script and o2switch deployment docs

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-30 09:22:48 +02:00
co-authored by Claude Sonnet 5
parent 360e0ee7a6
commit 0761f1b76d
4 changed files with 155 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import { loadConfig } from './config.js';
import { getPool, closePool } from './db.js';
import { uploadPath, outputPath, deleteIfExists } from './storage.js';
import { findExpiredJobs, deleteJob } from './jobs/jobRepository.js';
export async function runCleanup(pool, config) {
const expiredJobs = await findExpiredJobs(pool);
for (const job of expiredJobs) {
await deleteIfExists(uploadPath(config, job.id, job.sourceFormat));
await deleteIfExists(outputPath(config, job.id, job.targetFormat));
await deleteJob(pool, job.id);
}
return expiredJobs.length;
}
async function main() {
const config = loadConfig();
const pool = getPool(config);
const deletedCount = await runCleanup(pool, config);
console.log(`Cleanup: removed ${deletedCount} expired job(s).`);
await closePool();
}
if (import.meta.url === `file://${process.argv[1]}`) {
main();
}