public async Task OnStartedServiceAsync(OperationContext context, ICacheServerServices cacheServices) { CacheServiceStartup.UseExternalServices(WebHostBuilder, context, HostParameters); WebHostBuilder.ConfigureServices(services => { services.AddSingleton <DistributedCacheServiceConfiguration>(ServiceConfiguration); if (ServiceConfiguration.ContentCache != null) { if (cacheServices.PushFileHandler != null && cacheServices.StreamStore != null) { services.AddSingleton <ContentCacheService>(sp => { return(new ContentCacheService( ServiceConfiguration.ContentCache, cacheServices.PushFileHandler, cacheServices.StreamStore)); }); } } if (UseGrpc) { services.AddSingleton(cacheServices); var grpcServiceCollection = new ServiceCollectionWrapper(services); foreach (var grpcEndpoint in cacheServices.GrpcEndpoints) { grpcEndpoint.AddServices(grpcServiceCollection); } services.AddSingleton <BinderConfiguration>(MetadataServiceSerializer.BinderConfiguration); services.AddCodeFirstGrpc(); } }); WebHost = WebHostBuilder.Build(); // Get and start the DeploymentProxyService ProxyService = WebHost.Services.GetService <DeploymentProxyService>(); ContentCacheService = WebHost.Services.GetService <ContentCacheService>(); if (ProxyService != null) { await ProxyService.StartupAsync(context).ThrowIfFailureAsync(); } if (ContentCacheService != null) { await ContentCacheService.StartupAsync(context).ThrowIfFailureAsync(); } await WebHost.StartAsync(context.Token); }
public async Task OnStartedServiceAsync(OperationContext context, ICacheServerServices cacheServices) { CacheServiceStartup.UseExternalServices(WebHostBuilder, context, HostParameters); WebHostBuilder.ConfigureServices(services => { if (ServiceConfiguration.ContentCache != null) { if (cacheServices.PushFileHandler != null && cacheServices.StreamStore != null) { services.AddSingleton <ContentCacheService>(sp => { return(new ContentCacheService( ServiceConfiguration.ContentCache, cacheServices.PushFileHandler, cacheServices.StreamStore)); }); } } }); WebHost = WebHostBuilder.Build(); ConfigurationSource.Configuration = WebHost.Services.GetService <ProxyServiceConfiguration>(); // Get and start the DeploymentProxyService ProxyService = WebHost.Services.GetService <DeploymentProxyService>(); ContentCacheService = WebHost.Services.GetService <ContentCacheService>(); await ProxyService.StartupAsync(context).ThrowIfFailureAsync(); if (ContentCacheService != null) { await ContentCacheService.StartupAsync(context).ThrowIfFailureAsync(); } await WebHost.StartAsync(context.Token); }