Beispiel #1
0
        public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.logger = providerRuntime.GetLogger("Dashboard");

            var router = new Router();
            new DashboardController(router, TaskScheduler.Current,  providerRuntime);

            var options = new StartOptions
            {
                ServerFactory = "Nowin",
                Port = config.Properties.ContainsKey("Port") ? int.Parse(config.Properties["Port"]) : 8080,
            };

            var username = config.Properties.ContainsKey("Username") ? config.Properties["Username"] : null;
            var password = config.Properties.ContainsKey("Password") ? config.Properties["Password"] : null;
            try
            {
                host = WebApp.Start(options, app => new WebServer(router, username, password).Configuration(app));
            }
            catch (Exception ex)
            {
                this.logger.Error(10001, ex.ToString());
            }

            this.logger.Verbose($"Dashboard listening on {options.Port}");

            this.profiler = new GrainProfiler(TaskScheduler.Current, providerRuntime);

            var dashboardGrain = providerRuntime.GrainFactory.GetGrain<IDashboardGrain>(0);
            return dashboardGrain.Init();
        }
Beispiel #2
0
        public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.logger = providerRuntime.GetLogger("Dashboard");

            var router = new Router();

            new DashboardController(router, TaskScheduler.Current, providerRuntime);

            var options = new StartOptions
            {
                ServerFactory = "Nowin",
                Port          = config.Properties.ContainsKey("Port") ? int.Parse(config.Properties["Port"]) : 8080,
            };

            var username = config.Properties.ContainsKey("Username") ? config.Properties["Username"] : null;
            var password = config.Properties.ContainsKey("Password") ? config.Properties["Password"] : null;

            try
            {
                host = WebApp.Start(options, app => new WebServer(router, username, password).Configuration(app));
            }
            catch (Exception ex)
            {
                this.logger.Error(10001, ex.ToString());
            }

            this.logger.Verbose($"Dashboard listening on {options.Port}");

            this.profiler = new GrainProfiler(TaskScheduler.Current, providerRuntime);

            var dashboardGrain = providerRuntime.GrainFactory.GetGrain <IDashboardGrain>(0);

            return(dashboardGrain.Init());
        }
Beispiel #3
0
        public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.Name = name;

            this.logger = providerRuntime.GetLogger("Dashboard");

            this.dashboardTraceListener = new DashboardTraceListener();

            var router = new Router();

            this.controller = new DashboardController(router, TaskScheduler.Current, providerRuntime, dashboardTraceListener);

            var options = new StartOptions
            {
                ServerFactory = "Nowin",
                Port          = config.Properties.ContainsKey("Port") ? int.Parse(config.Properties["Port"]) : 8080,
            };

            var username = config.Properties.ContainsKey("Username") ? config.Properties["Username"] : null;
            var password = config.Properties.ContainsKey("Password") ? config.Properties["Password"] : null;

            try
            {
                host = WebApp.Start(options, app => new WebServer(router, username, password).Configuration(app));
                Trace.Listeners.Remove("HostingTraceListener");
            }
            catch (Exception ex)
            {
                this.logger.Error(10001, ex.ToString());
            }

            this.logger.Verbose($"Dashboard listening on {options.Port}");


            this.profiler = new GrainProfiler(TaskScheduler.Current, providerRuntime);


            var dashboardGrain = providerRuntime.GrainFactory.GetGrain <IDashboardGrain>(0);
            await dashboardGrain.Init();


            var siloGrain = providerRuntime.GrainFactory.GetGrain <ISiloGrain>(providerRuntime.ToSiloAddress());
            await siloGrain.SetOrleansVersion(typeof(SiloAddress).Assembly.GetName().Version.ToString());

            Trace.Listeners.Add(dashboardTraceListener);



            // horrible hack to grab the scheduler
            // to allow the stats publisher to push
            // counters to grains
            OrleansScheduler = TaskScheduler.Current;
        }
Beispiel #4
0
        public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.Name = name;

            this.logger = providerRuntime.GetLogger("Dashboard");

            this.dashboardTraceListener = new DashboardTraceListener();

            var port     = config.Properties.ContainsKey("Port") ? int.Parse(config.Properties["Port"]) : 8080;
            var hostname = config.Properties.ContainsKey("Host") ? config.Properties["Host"] : "*";

            var username = config.Properties.ContainsKey("Username") ? config.Properties["Username"] : null;
            var password = config.Properties.ContainsKey("Password") ? config.Properties["Password"] : null;

            var credentials = new UserCredentials(username, password);


            try
            {
                var builder = new WebHostBuilder()
                              .ConfigureServices(s => s
                                                 .AddSingleton(TaskScheduler.Current)
                                                 .AddSingleton(providerRuntime)
                                                 .AddSingleton(dashboardTraceListener)
                                                 )
                              .ConfigureServices(services =>
                {
                    services
                    .AddMvcCore()
                    .AddApplicationPart(typeof(DashboardController).Assembly)
                    .AddJsonFormatters();
                })
                              .Configure(app =>
                {
                    if (credentials.HasValue())
                    {
                        // only when usename and password are configured
                        // do we inject basicauth middleware in the pipeline
                        app.UseMiddleware <BasicAuthMiddleware>(credentials);
                    }

                    app.UseMvc();
                })
                              .UseKestrel()
                              .UseUrls($"http://{hostname}:{port}");
                host = builder.Build();
                host.Start();
            }
            catch (Exception ex)
            {
                this.logger.Error(10001, ex.ToString());
            }

            this.logger.Verbose($"Dashboard listening on {port}");

            this.profiler = new GrainProfiler(TaskScheduler.Current, providerRuntime);

            var dashboardGrain = providerRuntime.GrainFactory.GetGrain <IDashboardGrain>(0);
            await dashboardGrain.Init();

            var siloGrain = providerRuntime.GrainFactory.GetGrain <ISiloGrain>(providerRuntime.ToSiloAddress());
            await siloGrain.SetOrleansVersion(typeof(SiloAddress).Assembly.GetName().Version.ToString());

            Trace.Listeners.Add(dashboardTraceListener);

            // horrible hack to grab the scheduler
            // to allow the stats publisher to push
            // counters to grains
            OrleansScheduler = TaskScheduler.Current;
        }