Example #1
0
            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);
            }
Example #2
0
        public static Task RunAsync(string[] args, CancellationToken token)
        {
            if (args.ElementAtOrDefault(0)?.Equals("cacheService", StringComparison.OrdinalIgnoreCase) == true)
            {
                args = args.Skip(1).ToArray();
                return(CacheServiceStartup.RunWithCacheServiceAsync(args, token));
            }

            return(CreateHostBuilder(args).Build().RunAsync(token));
        }
Example #3
0
            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);
            }