2025-11-23 19:41:21 +01:00
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
|
|
|
import { createSupervisorClient } from '@/lib/supervisor/client';
|
2025-11-23 20:53:23 +01:00
|
|
|
import { withLogging } from '@/lib/utils/api-logger';
|
2025-11-23 19:41:21 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
export const POST = withLogging(async (request: NextRequest) => {
|
|
|
|
|
const body = await request.json();
|
|
|
|
|
const { signal } = body;
|
2025-11-23 19:41:21 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
if (!signal) {
|
2025-11-23 19:41:21 +01:00
|
|
|
return NextResponse.json(
|
2025-11-23 20:53:23 +01:00
|
|
|
{ error: 'Signal is required' },
|
|
|
|
|
{ status: 400 }
|
2025-11-23 19:41:21 +01:00
|
|
|
);
|
|
|
|
|
}
|
2025-11-23 20:53:23 +01:00
|
|
|
|
|
|
|
|
const client = createSupervisorClient();
|
|
|
|
|
const results = await client.signalAllProcesses(signal);
|
|
|
|
|
|
|
|
|
|
return NextResponse.json({
|
|
|
|
|
success: true,
|
|
|
|
|
message: `Signal ${signal} sent to all processes`,
|
|
|
|
|
results,
|
|
|
|
|
signal,
|
|
|
|
|
});
|
|
|
|
|
}, 'signalAllProcesses');
|