busy('engine_readiness'); if (!CloudAgentReadiness::wait()) { $heartbeat->error('engine_readiness_timeout'); fwrite(STDERR, "cloud lifecycle Go Agent readiness timed out\n"); // A prolonged Agent outage must not stop database-only // billing and expiry work forever. Skip host-backed // observations in the first tick; the next daemon pass // resumes normal per-stage isolation. $skipEngineObservations = true; } } $service = new CloudLifecycleService($heartbeat); do { $heartbeat->busy('lifecycle_tick'); try { // Skip only the first runtime observation after a // startup-readiness timeout. Database-only billing, // expiry and reconciliation still run; the next daemon // pass retries ordinary Agent observations. $skipThisTick = $skipEngineObservations; $skipEngineObservations = false; $service->tick(200, $skipThisTick); $errors = $service->observationErrors(); if ($errors === []) { $heartbeat->success(); } else { $heartbeat->error($errors[0]); } } catch (\Throwable $error) { $heartbeat->error('lifecycle_tick_failed'); fwrite(STDERR, 'cloud lifecycle temporarily unavailable: ' . get_class($error) . PHP_EOL); if ($once) { return 1; } } if (!$once) { usleep(15000000); } } while (!$once); } finally { $heartbeat->stopped(); } return 0; } }