// internal/virtual for tests (i.e. hack, do not port to netcore) internal virtual void DetermineRuntimeLevel(IUmbracoDatabaseFactory databaseFactory, IProfilingLogger profilingLogger) { using (var timer = profilingLogger.DebugDuration <CoreRuntime>("Determining runtime level.", "Determined.")) { try { _state.DetermineRuntimeLevel(databaseFactory); profilingLogger.Debug <CoreRuntime, RuntimeLevel, RuntimeLevelReason>("Runtime level: {RuntimeLevel} - {RuntimeLevelReason}", _state.Level, _state.Reason); if (_state.Level == RuntimeLevel.Upgrade) { profilingLogger.Debug <CoreRuntime>("Configure database factory for upgrades."); databaseFactory.ConfigureForUpgrade(); } } catch { _state.Level = RuntimeLevel.BootFailed; _state.Reason = RuntimeLevelReason.BootFailedOnException; timer?.Fail(); throw; } } }
private void DetermineRuntimeLevel() { if (State.BootFailedException is not null) { // There's already been an exception, so cannot boot and no need to check return; } using DisposableTimer? timer = _profilingLogger.DebugDuration <CoreRuntime>("Determining runtime level.", "Determined."); try { State.DetermineRuntimeLevel(); _logger.LogDebug("Runtime level: {RuntimeLevel} - {RuntimeLevelReason}", State.Level, State.Reason); if (State.Level == RuntimeLevel.Upgrade) { _logger.LogDebug("Configure database factory for upgrades."); _databaseFactory.ConfigureForUpgrade(); } } catch (Exception ex) { State.Configure(RuntimeLevel.BootFailed, RuntimeLevelReason.BootFailedOnException); timer?.Fail(); _logger.LogError(ex, "Boot Failed"); // We do not throw the exception, it will be rethrown by BootFailedMiddleware } }