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 OnStoppingServiceAsync(OperationContext context) { // Not passing cancellation token since it will already be signaled // WebHost is null for out-of-proc casaas case. if (WebHost != null) { await WebHost.StopAsync(); } if (ProxyService != null) { await ProxyService.ShutdownAsync(context).IgnoreFailure(); } if (ContentCacheService != null) { await ContentCacheService.ShutdownAsync(context).IgnoreFailure(); } WebHost?.Dispose(); }
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); }