- 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
35 lines
916 B
JavaScript
35 lines
916 B
JavaScript
// 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'
|
|
}
|
|
})
|
|
}
|