示例#1
0
        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;
        }
示例#2
0
        public virtual void OnStart(StageArgs args)
        {
            var registration = args.TryGetInstance <IConsulRegistration>();

            if (registration != null)
            {
                var client = new ConsulClient();
                client.Catalog.Register(registration.CreateRegistration());
            }
        }
示例#3
0
        public void OnStart(StageArgs args)
        {
            _startup = args.TryGetInstance <IStartup>();

            if (_startup == null)
            {
                throw new StartupNotFoundException();
            }

            _startup.Execute(new ServiceArgs(args.StartArgs, () => false));
        }
示例#4
0
        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();
        }
示例#5
0
 public void The_default_instance_factory_can_find_istartup_implementation()
 {
     _args
     .TryGetInstance <IStartup>()
     .ShouldBeOfType <TestApp>();
 }