2025-11-23 19:14:04 +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:14:04 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
export const POST = withLogging(async (request: NextRequest) => {
|
|
|
|
|
const body = await request.json().catch(() => ({}));
|
|
|
|
|
const wait = body.wait ?? true;
|
2025-11-23 19:14:04 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
const client = createSupervisorClient();
|
2025-11-23 19:14:04 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
// Stop all processes first
|
|
|
|
|
await client.stopAllProcesses(wait);
|
2025-11-23 19:14:04 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
// Then start them
|
|
|
|
|
const results = await client.startAllProcesses(wait);
|
2025-11-23 19:14:04 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
return NextResponse.json({
|
|
|
|
|
success: true,
|
|
|
|
|
message: 'Restarted all processes',
|
|
|
|
|
results,
|
|
|
|
|
wait,
|
|
|
|
|
});
|
|
|
|
|
}, 'restartAllProcesses');
|