recordAppLaunch method
Starts monitoring application startup for the given patchId.
Implementation
void recordAppLaunch(String? patchId) {
_activePatchId = patchId;
_isHealthy = false;
_healthTimer?.cancel();
if (patchId == null || patchId.isEmpty) {
// Running on clean base binary, inherently healthy
_isHealthy = true;
return;
}
final currentCrashes = storage.getConsecutiveCrashes(patchId);
logger.debug('Watchdog: Launching patch "$patchId" (consecutive crashes: $currentCrashes)');
if (currentCrashes >= maxCrashThreshold) {
_triggerSelfHealingRollback(patchId, 'Consecutive startup crash limit ($maxCrashThreshold) exceeded on launch');
return;
}
// Schedule healthy confirmation timer
_healthTimer = Timer(healthyThresholdDuration, () {
_isHealthy = true;
storage.setConsecutiveCrashes(patchId, 0);
logger.info('Watchdog: App startup confirmed stable for patch "$patchId". Crash counters reset.');
});
}