Ejemplo n.º 1
0
 public Dashboard(
     ILogger <Dashboard> logger,
     ILocalSiloDetails localSiloDetails,
     IGrainFactory grainFactory,
     IOptions <DashboardOptions> dashboardOptions,
     SiloDispatcher siloDispatcher)
 {
     this.logger           = logger;
     this.grainFactory     = grainFactory;
     this.siloDispatcher   = siloDispatcher;
     this.localSiloDetails = localSiloDetails;
     this.dashboardOptions = dashboardOptions.Value;
 }
Ejemplo n.º 2
0
        public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            Name = name;

            var options = providerRuntime.ServiceProvider.GetRequiredService <IOptions <DashboardOptions> >();

            if (options.Value.HostSelf)
            {
                var logger = providerRuntime.ServiceProvider.GetRequiredService <ILogger <Dashboard> >();

                try
                {
                    host =
                        new WebHostBuilder()
                        .ConfigureServices(services =>
                    {
                        services.AddServicesForHostedDashboard(providerRuntime.GrainFactory, options);
                    })
                        .Configure(app =>
                    {
                        if (options.Value.HasUsernameAndPassword())
                        {
                            // only when usename and password are configured
                            // do we inject basicauth middleware in the pipeline
                            app.UseMiddleware <BasicAuthMiddleware>();
                        }

                        app.UseOrleansDashboard();
                    })
                        .UseKestrel()
                        .UseUrls($"http://{options.Value.Host}:{options.Value.Port}")
                        .Build();

                    host.Start();
                }
                catch (Exception ex)
                {
                    logger.Error(10001, ex.ToString());
                }

                logger.LogInformation($"Dashboard listening on {options.Value.Port}");
            }

            // horrible hack to grab the scheduler
            // to allow the stats publisher to push
            // counters to grains
            SiloDispatcher.Setup();

            await ActivateDashboardGrainAsync(providerRuntime);
            await ActivateSiloGrainAsync(providerRuntime);
        }
        public Task Execute(CancellationToken cancellationToken)
        {
            if (dashboardOptions.HostSelf)
            {
                try
                {
                    host =
                        new WebHostBuilder()
                        .ConfigureServices(services =>
                    {
                        services.AddServicesForHostedDashboard(grainFactory, dashboardOptions);
                    })
                        .Configure(app =>
                    {
                        if (dashboardOptions.HasUsernameAndPassword())
                        {
                            // only when usename and password are configured
                            // do we inject basicauth middleware in the pipeline
                            app.UseMiddleware <BasicAuthMiddleware>();
                        }

                        app.UseOrleansDashboard();
                    })
                        .UseKestrel()
                        .UseUrls($"http://{dashboardOptions.Host}:{dashboardOptions.Port}")
                        .Build();

                    host.Start();
                }
                catch (Exception ex)
                {
                    logger.Error(10001, ex.ToString());
                }

                logger.LogInformation($"Dashboard listening on {dashboardOptions.Port}");
            }

            // horrible hack to grab the scheduler
            // to allow the stats publisher to push
            // counters to grains
            SiloDispatcher.Setup();

            return(Task.WhenAll(
                       ActivateDashboardGrainAsync(),
                       ActivateSiloGrainAsync()));
        }
        public void Dispose()
        {
            try
            {
                host?.Dispose();
            }
            catch
            {
                /* NOOP */
            }

            try
            {
                // Teardown the silo dispatcher to prevent deadlocks.
                SiloDispatcher.Teardown();
            }
            catch
            {
                /* NOOP */
            }
        }
Ejemplo n.º 5
0
        public Task Close()
        {
            try
            {
                host?.Dispose();
            }
            catch
            {
                /* NOOP */
            }

            try
            {
                // Teardown the silo dispatcher to prevent deadlocks.
                SiloDispatcher.Teardown();
            }
            catch
            {
                /* NOOP */
            }

            return(Task.CompletedTask);
        }