Exemplo n.º 1
0
        public StatusModule(ILoggerFactory loggerFactory, IHealthCheck healthCheck = null)
        {
            var logger = loggerFactory.CreateLogger("Microphone.Nancy");

            Get("/status", async req =>
            {
                if (healthCheck != null)
                {
                    await healthCheck.CheckHealth();
                }
                logger.LogInformation("OK");
                return(Environment.MachineName);
            });
        }
        public async Task <object> Get()
        {
            var machine = System.Environment.MachineName;

            _log.LogInformation("Status OK");
            if (_checkHealth != null)
            {
                await _checkHealth.CheckHealth();
            }
            var status = new {
                Machine = machine,
                Result  = "OK",
            };

            return(status);
        }
        public async Task <object> Get()
        {
            var machine = Environment.MachineName;

            Startup.LastHealthCheck = DateTime.UtcNow;
            if (_logger != null)
            {
                _logger.LogInformation("Status OK");
                if (_healthCheck != null)
                {
                    await _healthCheck.CheckHealth();
                }
            }
            var status = new
            {
                Machine = machine,
                Result  = "OK",
            };

            return(status);
        }
Exemplo n.º 4
0
        private void StartHeartbeat(Func <Task> registerService)
        {
            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    try
                    {
                        if (_healthCheck != null)
                        {
                            await _healthCheck.CheckHealth();
                        }
                        await registerService();
                        _log.LogInformation("OK");
                    }
                    catch
                    {
                    }

                    await Task.Delay(TimeSpan.FromSeconds(_ectdHeartbeart));
                }
            });
        }