From 56409b116102a8bf3c55d2a4d4bf757554859b09 Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Fri, 18 Jul 2025 13:09:23 +0200 Subject: [PATCH] feat: add manual cleanup API endpoint - Added POST /api/cleanup endpoint for manual process cleanup - Added GET /api/cleanup endpoint to check cleanup status - Enables manual triggering of aggressive cleanup via API - Useful for testing and manual maintenance --- app/api/cleanup/route.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/api/cleanup/route.js diff --git a/app/api/cleanup/route.js b/app/api/cleanup/route.js new file mode 100644 index 0000000..519ee4c --- /dev/null +++ b/app/api/cleanup/route.js @@ -0,0 +1,34 @@ +// API endpoint to manually trigger cleanup +import { NextResponse } from 'next/server' + +export async function POST() { + try { + console.log('🧹 Manual cleanup triggered via API...') + + // Import and trigger cleanup + const { aggressiveCleanup } = await import('../../../lib/startup') + await aggressiveCleanup.cleanupOrphanedProcesses() + + return NextResponse.json({ + success: true, + message: 'Cleanup completed successfully' + }) + } catch (error) { + console.error('Error in manual cleanup:', error) + return NextResponse.json({ + success: false, + error: error.message + }, { status: 500 }) + } +} + +export async function GET() { + // Return cleanup status + return NextResponse.json({ + message: 'Cleanup endpoint is active', + endpoints: { + 'POST /api/cleanup': 'Trigger manual cleanup', + 'GET /api/cleanup': 'Check cleanup status' + } + }) +}