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 void OnStart(StageArgs args) { var name = _attributes.OfType <AssemblyTitleAttribute>().SingleOrDefault()?.Title; var description = _attributes.OfType <AssemblyDescriptionAttribute>().SingleOrDefault()?.Description; args.Metadata.Name = name ?? string.Empty; args.Metadata.Description = description ?? string.Empty; }
public void When_an_IStartup_implementation_cannot_be_found() { var args = new StageArgs(new string[0]) { InstanceFactory = type => null }; Should.Throw <StartupNotFoundException>(() => _asyncRunner.OnStart(args)); }
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 OnStop(StageArgs args) { try { _source.Cancel(); _runner.Wait(); } catch (TaskCanceledException) { } (_startup as IDisposable)?.Dispose(); }
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_args_used_in_stop_are_same_as_start() { StageArgs startArgs = null; StageArgs stopArgs = null; var stage = new TestStage((ts, a) => startArgs = a, (ts, a) => stopArgs = a); var pipeline = new Pipeline(new[] { stage }); pipeline.OnStart(new string[0]); pipeline.OnStop(); stopArgs.ShouldBe(startArgs); }
public virtual void OnStart(StageArgs args) { _container = new Container(c => { c.Scan(a => { a.TheCallingAssembly(); a.LookForRegistries(); a.Convention <AllInterfacesConvention>(); a.WithDefaultConventions(); }); }); args.InstanceFactory = _container.TryGetInstance; }
public ServiceMetadataStageTests() { _stageArgs = new StageArgs(new string[0]); }
public void OnStop(StageArgs args) { throw new System.NotImplementedException(); }
public void OnStop(StageArgs args) { (_startup as IDisposable)?.Dispose(); }
public virtual void OnStop(StageArgs args) { _container?.Dispose(); }
public void OnStop(StageArgs args) { }
public StageArgsTests() { _args = new StageArgs(new PipelineCustomisation(), new string[0]); }
public virtual void OnStop(StageArgs args) { AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException; }
public StageArgsTests() { _args = new StageArgs(new string[0]); }
public virtual void OnStart(StageArgs args) => _onExecute?.Invoke(this, args);
public virtual void OnStop(StageArgs args) => _onDispose?.Invoke(this, args);