Operations for Laravel
Self-heal stalled operations
Self-heal stalled operations
Pass an expiresAt deadline when starting work that could hang:
$operations->start(new StartOperation(
kind: 'provision',
steps: ['order', 'boot', 'configure'],
expiresAt: now()->addMinutes(20),
));
Schedule the sweep so a worker that crashed mid-run doesn't leave a stuck
running record:
use Illuminate\Support\Facades\Schedule;
Schedule::command('operations:sweep-stalled')->everyMinute();
The sweep fails every running operation whose expires_at has passed, with the
error stalled: deadline exceeded. Operations without a deadline are never swept.
You can also call it directly: app(Operations::class)->sweepStalled().