public async Task <IActionResult> IndexAsync()
        {
            if (_lastHealthCheckResult == null || _nextHealthCheckTimeUtc < SystemClock.UtcNow)
            {
                _nextHealthCheckTimeUtc = SystemClock.UtcNow.AddSeconds(5);
                _lastHealthCheckResult  = await _healthChecker.CheckAllAsync();
            }

            if (!_lastHealthCheckResult.IsHealthy)
            {
                return(StatusCodeWithMessage(StatusCodes.Status503ServiceUnavailable, _lastHealthCheckResult.Message, _lastHealthCheckResult.Message));
            }

            if (Settings.Current.HasAppScope)
            {
                return(Ok(new {
                    Message = "All Systems Check",
                    Settings.Current.InformationalVersion,
                    Settings.Current.AppScope,
                    AppMode = Settings.Current.AppMode.ToString(),
                    Environment.MachineName
                }));
            }

            return(Ok(new {
                Message = "All Systems Check",
                Settings.Current.InformationalVersion,
                AppMode = Settings.Current.AppMode.ToString(),
                Environment.MachineName
            }));
        }
Example #2
0
        public async Task <IHttpActionResult> IndexAsync()
        {
            if (_lastHealthCheckResult == null || _nextHealthCheckTimeUtc < DateTime.UtcNow)
            {
                _nextHealthCheckTimeUtc = DateTime.UtcNow.AddSeconds(5);
                _lastHealthCheckResult  = await _healthChecker.CheckAllAsync();
            }

            if (!_lastHealthCheckResult.IsHealthy)
            {
                return(StatusCodeWithMessage(HttpStatusCode.ServiceUnavailable, _lastHealthCheckResult.Message, _lastHealthCheckResult.Message));
            }

            if (Settings.Current.HasAppScope)
            {
                return(Ok(new {
                    Message = "All Systems Check",
                    Settings.Current.Version,
                    Settings.Current.AppScope,
                    WebsiteMode = Settings.Current.WebsiteMode.ToString(),
                    Environment.MachineName
                }));
            }

            return(Ok(new {
                Message = "All Systems Check",
                Settings.Current.Version,
                WebsiteMode = Settings.Current.WebsiteMode.ToString(),
                Environment.MachineName
            }));
        }
        public async Task <IHttpActionResult> Index()
        {
            var result = await _healthChecker.CheckAllAsync();

            if (!result.IsHealthy)
            {
                return(StatusCodeWithMessage(HttpStatusCode.ServiceUnavailable, result.Message));
            }

            return(Ok(new StatusResult {
                Message = "All Systems Check", Version = Settings.Current.Version
            }));
        }
        public async Task <IHttpActionResult> IndexAsync()
        {
            if (_lastHealthCheckResult == null || _nextHealthCheckTimeUtc < DateTime.UtcNow)
            {
                _nextHealthCheckTimeUtc = DateTime.UtcNow.AddSeconds(5);
                _lastHealthCheckResult  = await _healthChecker.CheckAllAsync();
            }

            if (!_lastHealthCheckResult.IsHealthy)
            {
                return(StatusCodeWithMessage(HttpStatusCode.ServiceUnavailable, _lastHealthCheckResult.Message, _lastHealthCheckResult.Message));
            }

            return(Ok(new StatusResult {
                Message = "All Systems Check", Version = Settings.Current.Version
            }));
        }
        public async Task CheckAllAsync()
        {
            var health = await _checker.CheckAllAsync();

            Assert.True(health.IsHealthy, health.Message);
        }