feat: add cleanup script and o2switch deployment docs
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user