Exemplo n.º 1
0
        public virtual async Task InitializeAsync(IVostokHostingEnvironment environment)
        {
            var log = environment.Log.ForContext <VostokAspNetCoreApplication>();

            var builder = new VostokAspNetCoreApplicationBuilder <TStartup>(environment, this, disposables);

            builder.SetupPingApi(
                settings =>
            {
                settings.CommitHashProvider  = GetCommitHash;
                settings.InitializationCheck = () => initialized;

                if (environment.HostExtensions.TryGet <IVostokApplicationDiagnostics>(out var diagnostics))
                {
                    settings.HealthCheck = () => diagnostics.HealthTracker.CurrentStatus == HealthStatus.Healthy;
                }
            });

            Setup(builder, environment);

            disposables.Add(manager = new HostManager(builder.BuildHost(), log));

            await manager.StartHostAsync(environment.ShutdownToken);

            await WarmupAsync(environment, manager.Services);

            await WarmupMiddlewares(environment);

            initialized.TrySetTrue();
        }
        public async Task InitializeAsync(IVostokHostingEnvironment environment)
        {
            var log = environment.Log.ForContext <VostokAspNetCoreApplication>();

            var builder = new VostokAspNetCoreApplicationBuilder <TStartup>(environment, disposables);

            builder.SetupPingApi(
                settings =>
            {
                settings.InitializationCheck = () => initialized;
                settings.CommitHashProvider  = GetCommitHash;
            });

            Setup(builder, environment);

            disposables.Add(manager = new HostManager(builder.BuildHost(), log));

            await manager.StartHostAsync(environment.ShutdownToken);

            await WarmupAsync(environment, manager.Services);

            initialized.TrySetTrue();
        }