/// <inheritdoc /> protected override void OnStart(string[] args) { var port = Settings.Default.Port; var url = Environment.UserInteractive ? $"http://localhost:{port}/" : $"http://+:{port}/"; var readableUrl = url.Replace("+", Environment.MachineName); Console.Write("Starting API at "); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(readableUrl); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(); Console.WriteLine(); _api = WebApp.Start <Startup>(url); _logging = ObjectFactory.GetInstance <ILogging>(); _executor = ObjectFactory.GetInstance <IExecutor>(); _timeProvider = ObjectFactory.GetInstance <ITimeProvider>(); _healthCounterRepository = ObjectFactory.GetInstance <IHealthCounterRepository>(); _timer = new System.Timers.Timer() { Interval = TimeSpan.FromSeconds(10).TotalMilliseconds, Enabled = true, AutoReset = false, }; _timer.Elapsed += this.Pulse; _logging.LogDebug($"Service OnStart done. API started at {readableUrl}"); }
public PulseHealthCheck(IHealthCounterRepository healthCounterRepository) { if (healthCounterRepository == null) { throw new ArgumentNullException(nameof(healthCounterRepository)); } _healthCounterRepository = healthCounterRepository; }