probe(fn () => DB::select('select 1')); $storage = $this->probe(function (): void { $path = 'health/'.gethostname().'.probe'; Storage::disk(config('filesystems.default'))->put($path, now()->toISOString()); Storage::disk(config('filesystems.default'))->delete($path); }); $heartbeat = Cache::get('system:scheduler-heartbeat'); $queueHeartbeat = Cache::get('system:queue-heartbeat'); $queue = config('queue.default') === 'sync' ? 'local' : ($queueHeartbeat && now()->diffInMinutes($queueHeartbeat) < 3 ? 'ok' : 'degraded'); $services = [ 'api' => 'ok', 'database' => $database, 'storage' => $storage, 'queue' => $queue, 'scheduler' => $heartbeat && now()->diffInMinutes($heartbeat) < 3 ? 'ok' : 'degraded', 'mail' => config('mail.default') === 'log' ? 'local' : 'configured', 'websocket' => config('broadcasting.default') === 'log' ? 'degraded' : 'configured', 'exportWorker' => $queue, 'aiProvider' => config('ai.provider', 'local-structuring'), ]; $ok = $database === 'ok' && $storage === 'ok'; return response()->json(['data' => ['status' => $ok ? 'ok' : 'degraded', 'deploymentMode' => $deployment->mode()->value, 'services' => $services, 'checkedAt' => now()->toISOString()]], $ok ? 200 : 503); } private function probe(callable $callback): string { try { $callback(); return 'ok'; } catch (Throwable) { return 'failed'; } } }