26 lines
746 B
TypeScript
26 lines
746 B
TypeScript
|
|
import { NextRequest, NextResponse } from 'next/server';
|
||
|
|
import { createSupervisorClient } from '@/lib/supervisor/client';
|
||
|
|
|
||
|
|
// POST - Stop all processes
|
||
|
|
export async function POST(request: NextRequest) {
|
||
|
|
try {
|
||
|
|
const body = await request.json().catch(() => ({}));
|
||
|
|
const wait = body.wait ?? true;
|
||
|
|
|
||
|
|
const client = createSupervisorClient();
|
||
|
|
const results = await client.stopAllProcesses(wait);
|
||
|
|
|
||
|
|
return NextResponse.json({
|
||
|
|
success: true,
|
||
|
|
message: 'Stopped all processes',
|
||
|
|
results,
|
||
|
|
});
|
||
|
|
} catch (error: any) {
|
||
|
|
console.error('Supervisor stop all processes error:', error);
|
||
|
|
return NextResponse.json(
|
||
|
|
{ error: error.message || 'Failed to stop all processes' },
|
||
|
|
{ status: 500 }
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|