public virtual void OnStart(StageArgs args) { var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; var logs = Path.Combine(baseDirectory, "logs"); Directory.CreateDirectory(logs); var logConfig = new LoggerConfiguration() .Enrich.FromLogContext() .Enrich.WithProperty("SoftwareName", _serviceName) .WriteTo.ColoredConsole() .WriteTo.RollingFile(logs); var config = args.TryGetInstance <ILogConfig>(); if (config != null && config.EnableKibana) { logConfig.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(config.LoggingEndpoint) { AutoRegisterTemplate = true }); } Log.Logger = logConfig.CreateLogger(); AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; }
public virtual void OnStart(StageArgs args) { var registration = args.TryGetInstance <IConsulRegistration>(); if (registration != null) { var client = new ConsulClient(); client.Catalog.Register(registration.CreateRegistration()); } }
public void OnStart(StageArgs args) { _startup = args.TryGetInstance <IStartup>(); if (_startup == null) { throw new StartupNotFoundException(); } _startup.Execute(new ServiceArgs(args.StartArgs, () => false)); }
public virtual void OnStart(StageArgs args) { _startup = args.TryGetInstance <IStartup>(); if (_startup == null) { throw new StartupNotFoundException(); } _serviceArgs = new ServiceArgs(args.StartArgs, () => _source.IsCancellationRequested); _runner.Start(); }
public void The_default_instance_factory_can_find_istartup_implementation() { _args .TryGetInstance <IStartup>() .ShouldBeOfType <TestApp>(); }