import { NextRequest, NextResponse } from 'next/server'; import { createSupervisorClient } from '@/lib/supervisor/client'; // POST - Restart all processes (stop then start) export async function POST(request: NextRequest) { try { const body = await request.json().catch(() => ({})); const wait = body.wait ?? true; const client = createSupervisorClient(); // Stop all processes first await client.stopAllProcesses(wait); // Then start them const results = await client.startAllProcesses(wait); return NextResponse.json({ success: true, message: 'Restarted all processes', results, }); } catch (error: any) { console.error('Supervisor restart all processes error:', error); return NextResponse.json( { error: error.message || 'Failed to restart all processes' }, { status: 500 } ); } }