public async Task InitTest()
        {
            var builder = new SiloHostBuilder()
                          .UseLocalhostClustering()
                          .ConfigureServices((hostBuilderContext, services) =>
            {
                ConfigureServices(services);
            })
                          .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = "dev";
                options.ServiceId = "TEST";
            })
                          .AddMemoryGrainStorage("MemoryStorage")
                          .AddMemoryGrainStorage("PubSubStore")
                          .AddMemoryGrainStorage("StorageProvider")
                          .AddPersistentStreams("TestStreamProvider", new TestAdapterFactory.FactoryProvider(ProvideMessages, OnMessagesDelivered).Create, streamBuilder =>
                                                streamBuilder.Configure <StreamPullingAgentOptions>(ob =>
                                                                                                    ob.Configure(options => options.GetQueueMsgsTimerPeriod = TimeSpan.FromMilliseconds(100))
                                                                                                    ))
                          .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(FailedToHandleMessageTestGrain).Assembly).WithReferences())
                          .ConfigureLogging(logging => logging.AddConsole());

            _host = builder.Build();
            this.ServiceProvider = _host.Services;
            await _host.StartAsync().ConfigureAwait(false);
        }
Esempio n. 2
0
        static async Task Main(string[] args)
        {
            using (SentrySdk.Init(Dsn))
            {
                ISiloHostBuilder siloBuilder = new SiloHostBuilder()
                                               .UseLocalhostClustering()
                                               .AddMemoryGrainStorageAsDefault()
                                               .AddStartupTask(
                    (provider, token) => provider.GetRequiredService <IGrainFactory>()
                    .GetGrain <IGame>(0)
                    .InitGame(true))
                                               .ConfigureAppConfiguration(
                    (context, configure) => configure
                    .AddJsonFile(
                        "appsettings.json",
                        optional: false)
                    .AddJsonFile(
                        $"appsettings.{context.HostingEnvironment}.json",
                        optional: true)
                    .AddEnvironmentVariables()
                    .AddCommandLine(args))
                                               .ConfigureServices(Configure);

                ISiloHost silo = siloBuilder.Build();
                await silo.StartAsync();

                var closeEvent = new AutoResetEvent(false);
                Console.CancelKeyPress += (sender, e) => { closeEvent.Reset(); };
                closeEvent.WaitOne();
                silo.Services.GetService <ILogger <Program> >().LogInformation("stopping");
                await silo.StopAsync();
            }
        }
Esempio n. 3
0
 protected Task RunSilo()
 {
     try
     {
         var builder = new SiloHostBuilder();
         builder.Configure <EndpointOptions>(options => options.AdvertisedIPAddress = IPAddress.Loopback)
         .UseLocalhostClustering()
         .Configure <ClusterOptions>(options =>
         {
             options.ClusterId = TableRoom.GameConstant.ClusterId;
             options.ServiceId = TableRoom.GameConstant.ServiceId;
         })
         .Configure <GrainCollectionOptions>(options =>
         {
             options.CollectionAge       = TimeSpan.FromSeconds(61);
             options.DeactivationTimeout = TimeSpan.FromSeconds(5);
             options.CollectionQuantum   = TimeSpan.FromSeconds(1);
         })
         .ConfigureLogging(log => log.SetMinimumLevel(LogLevel.Error).AddConsole());//LogLevel.Warning
         builder.ConfigureApplicationParts(parts =>
         {
             parts.AddApplicationPart(typeof(GChatRoomEntry).Assembly).WithReferences();
         });
         m_Host = builder.Build();
         m_Host.StartAsync().Wait();
     }
     catch (Exception e)
     {
         Log.Debug(e.ToString());
     }
     return(Task.CompletedTask);
 }
Esempio n. 4
0
        static async Task StartSilo()
        {
            Console.WriteLine("Silo is starting. Please wait.");
            await silo.StartAsync();

            _siloStarted.Set();
        }
        private Task RunAsync(CancellationToken cancellationToken)
        {
            var siloEndpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["OrleansSiloEndpoint"].IPEndpoint;

            var gatewayPort = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[@"OrleansGatewayEndpoint"].IPEndpoint.Port;

            Trace.TraceInformation($@"Endpoint: {siloEndpoint.Address.ToString()}:{gatewayPort}");

            var builder = new SiloHostBuilder()
                          .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = @"ForFunctions";
                options.ServiceId = @"AzureFunctionsSample";
            })
                          .Configure <EndpointOptions>(opt =>
            {
                // Our advertised IP is the one that our friendly DNS name resolves to
                var cloudServiceHostname = Dns.GetHostEntry(RoleEnvironment.GetConfigurationSettingValue(@"CloudServiceDnsName"));
                opt.AdvertisedIPAddress  = cloudServiceHostname.AddressList.First(a => a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);

                opt.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Any, gatewayPort);
                opt.GatewayPort           = gatewayPort;
                opt.SiloListeningEndpoint = new IPEndPoint(IPAddress.Any, siloEndpoint.Port);
                opt.SiloPort = siloEndpoint.Port;
            })
                          .UseAzureStorageClustering(opt => opt.ConnectionString = RoleEnvironment.GetConfigurationSettingValue(@"ClusterStorageConnectionString"))
                          .ConfigureApplicationParts(mgr =>
            {
                mgr.AddApplicationPart(typeof(GreetGrain).Assembly).WithReferences();
            });

            siloHost = builder.Build();

            return(siloHost.StartAsync(cancellationToken));
        }
Esempio n. 6
0
        private static void StartSilo(int portAddition)
        {
            var devEnvironmentVariable = Environment.GetEnvironmentVariable("NETCORE_ENVIRONMENT");
            var isDevelopment          = string.IsNullOrEmpty(devEnvironmentVariable) || devEnvironmentVariable.ToLower() == "development";
            var configurationBuilder   = new ConfigurationBuilder()
                                         .SetBasePath(Path.Combine(AppContext.BaseDirectory))
                                         .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            if (isDevelopment)
            {
                configurationBuilder.AddUserSecrets <Program>();
            }
            var configuration = configurationBuilder.Build();
            // define the cluster configuration
            var builder = new SiloHostBuilder()
                          //.UseLocalhostClustering()
                          .UseAzureStorageClustering(op => { op.ConnectionString = configuration["StorageClustering"]; })
                          .AddMemoryGrainStorage("OrleansStorage")
                          .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = "dev";
                options.ServiceId = "HelloWorldApp";
            })
                          .UseDashboard(options => { options.Port = 8080 + portAddition; })
                          .ConfigureEndpoints(siloPort: 11111 + portAddition, gatewayPort: 30000 + portAddition)
                          .Configure <EndpointOptions>(options =>
            {
                options.AdvertisedIPAddress = IPAddress.Loopback;
            })
                          .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(CheckingAccountGrain).Assembly).WithReferences())
                          .ConfigureLogging(logging => logging.AddConsole());

            _siloHost = builder.Build();
            _siloHost.StartAsync();
        }
Esempio n. 7
0
        private async Task StartSilo(int portAdd)
        {
            var builder = new SiloHostBuilder()
                          .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = "dev";
                options.ServiceId = "OrleansDemo";
            })
                          .UseAdoNetClustering(options =>
            {
                options.Invariant        = "System.Data.SqlClient";
                options.ConnectionString = _config.GetConnectionString("ClusterStorage");
            })
                          .AddAdoNetGrainStorage("Devices", options =>
            {
                options.Invariant        = "System.Data.SqlClient";
                options.ConnectionString = _config.GetConnectionString("GrainStorage");
                options.UseJsonFormat    = true;
            })
                          .ConfigureEndpoints(siloPort: 11111 + portAdd, gatewayPort: 30000 + portAdd)
                          .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory())
                          .UseDashboard(_ => { })
                          .UseLinuxEnvironmentStatistics()
                          .ConfigureLogging(logging => logging.AddConsole());

            _host = builder.Build();
            await _host.StartAsync();

            _logger.LogInformation("Host started.");
        }
        protected virtual async Task <ISiloHost> InitTestHost()
        {
            var siloAddress = IPAddress.Loopback;
            var builder     = new SiloHostBuilder()
                              .UseDevelopmentClustering(options => options.PrimarySiloEndpoint = new IPEndPoint(siloAddress, siloPort))
                              .ConfigureEndpoints(siloAddress, siloPort, gatewayPort)
                              .ConfigureServices(ConfigureServices)
                              .AddKafkaEventBusStreams("EventBus",
                                                       kafka =>
            {
                kafka.BrokerList = "kafka1:9094,kafka2:9094";
            },
                                                       receiver =>
            {
                receiver.ConsumerGroup = "test";
                receiver.TopicList     = new List <string> {
                    "testA", "testB"
                };
                receiver.TotalQueueCount = 8;
            });

            host = builder.Build();
            await host.StartAsync();

            return(host);
        }
Esempio n. 9
0
        public async Task StartSilo()
        {
            // define the cluster configuration
            var builder = new SiloHostBuilder()
                          .UseLocalhostClustering()
                          .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = "Maddalena";
                options.ServiceId = "Maddalena";
            })
                          .Configure <EndpointOptions>(options =>
            {
                options.AdvertisedIPAddress = IPAddress.Loopback;
            })
                          .UseDashboard(options =>
            {
                options.HostSelf  = false;
                options.HideTrace = true;
            })
                          .ConfigureApplicationParts(parts =>
            {
                parts.AddApplicationPart(typeof(EmptyGrain).Assembly)
                .WithReferences();
            })
                          .ConfigureLogging(logging => logging.AddConsole())
                          .AddStartupTask <HostStartup>();

            _host = builder.Build();
            await _host.StartAsync();
        }
Esempio n. 10
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Orleans Silo starting...");
            var builder = new SiloHostBuilder()
                          .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = _orleansConfig.ClusterId;
                options.ServiceId = Constants.ServiceId;
            })
                          .Configure <GrainCollectionOptions>(options => { options.CollectionAge = TimeSpan.FromMinutes(5); })
                          .ConfigureApplicationParts(parts =>
            {
                parts.AddApplicationPart(typeof(IGrainMarker).Assembly).WithReferences();
            })
                          .ConfigureServices(svcCollection =>
            {
                ConfigureServices.RegisterServices(_configuration, svcCollection);
            })
                          .UsePerfCounterEnvironmentStatistics()
                          .UseDashboard(options =>
            {
                options.Port = _orleansConfig.OrleansDashboardPort;
                options.CounterUpdateIntervalMs = 10000;
            });

            ConfigureClustering(builder);
            ConfigureLoadShedding(builder);
            ConfigureLogging(builder);

            _silo = builder.Build();
            await _silo.StartAsync(cancellationToken);
        }
        public static async Task StartSilo()
        {
            try
            {
                _hostName = Dns.GetHostName();
                var ips = await Dns.GetHostAddressesAsync(_hostName);

                _siloIP = ips.FirstOrDefault();

                var configRoot = GetConfiguration();
                var builder    = new SiloHostBuilder()
                                 .WithClusterConfig(configRoot)
                                 .WithParts()
                                 .WithMembership(configRoot)
                                 .ConfigureLogging(logging =>
                {
                    logging.AddConfiguration(configRoot.GetSection("Logging")).AddConsole();
                    //logging.AddFile("./debug.txt");
                });

                _siloHost = builder.Build();
                await _siloHost.StartAsync();
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
                Console.WriteLine("Failure Starting silo.");
                throw exc;
            }
        }
Esempio n. 12
0
        public static async Task <int> LogAndRun(ISiloHost siloHost)
        {
            Log.Logger = BuildLogger(siloHost.Services.GetRequiredService <IConfiguration>());

            try
            {
                Log.Information("Starting application.");
                await siloHost.StartAsync();

                Log.Information("Started application");

                Console.Read();

                Log.Information("Stopping application");
                await siloHost.StopAsync();

                Log.Information("Stopped application");

                return(0);
            }
            catch (Exception exception)
            {
                Log.Fatal(exception, "Application terminated unexpectedly");
                return(1);
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Starting Orleans cluster.");
            await _siloHost.StartAsync(cancellationToken);

            _logger.LogInformation("Orleans cluster running.");
        }
Esempio n. 14
0
        public static async Task StartSilo()
        {
            try
            {
                var configRoot = GetConfiguration();
                var builder    = new SiloHostBuilder()
                                 .WithClusterConfig(configRoot)
                                 .WithParts()
                                 .WithRabbitMQ(configRoot)
                                 .ConfigureLogging(logging =>
                {
                    logging.AddConfiguration(configRoot.GetSection("Logging")).AddConsole();
                    //logging.AddFile("./debug.txt");
                });

                _siloHost = builder.Build();
                await _siloHost.StartAsync();
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
                Console.WriteLine("Failure Starting silo.");
                throw exc;
            }
        }
Esempio n. 15
0
        public static async Task Start()
        {
            // define the cluster configuration
            var config = new ClusterConfiguration
            {
                Globals =
                {
                    AdoInvariant                     = ServiceContext.Invariant,
                    DataConnectionString             = ServiceContext.OrleansConnectionString,
                    LivenessType                     = GlobalConfiguration.LivenessProviderType.AdoNet,
                    ClusterId                        = ServiceContext.ClusterId,
                    ServiceId                        = Guid.Empty,
                    ReminderServiceType              = GlobalConfiguration.ReminderServiceProviderType.AdoNet,
                    AdoInvariantForReminders         = ServiceContext.Invariant,
                    DataConnectionStringForReminders = ServiceContext.OrleansConnectionString,
                },
                PrimaryNode = null
            };

            config.Globals.SeedNodes.Clear();

            //config.Globals.RegisterBootstrapProvider<>();
            //config.AddMemoryStorageProvider();
            var siloPort    = ServiceContext.SiloPort;
            var gatewayPort = ServiceContext.GatewayPort;

            Console.WriteLine($"准备监听 SiloPort:{siloPort} GatewayPort:{gatewayPort}");

            var builder = new SiloHostBuilder()
                          .ConfigureEndpoints(ServiceContext.HostName, siloPort, gatewayPort, listenOnAnyHostAddress: true)
                          .UseConfiguration(config)
                          .AddAdoNetGrainStorageAsDefault(options =>
            {
                options.Invariant        = ServiceContext.Invariant;
                options.ConnectionString = ServiceContext.OrleansConnectionString;
                options.UseJsonFormat    = true;
            })
                          .UseDashboard(options => { options.Port = ServiceContext.DashboardPort; })
                          .ConfigureApplicationParts(parts => parts.AddFromAppDomain().AddFromApplicationBaseDirectory())
                          .ConfigureLogging(logging =>
            {
                logging.AddNLog();
                //logging.AddConsole();
                logging.SetMinimumLevel(LogLevel.Trace);
            })
                          .AddMemoryGrainStorage("PubSubStore")
                          //.AddSimpleMessageStreamProvider("AccountBalanceStreamProvider")
                          .UseInClusterTransactionManager()
                          .UseInMemoryTransactionLog()
                          .UseTransactionalState();

            //.AddStartupTask(
            //    async (services, cancellation) =>
            //    {
            //        var isLog = ExtAccountContext.IsLog;
            //    });

            _host = builder.Build();
            await _host.StartAsync();
        }
        protected virtual async Task <ISiloHost> InitTestHost()
        {
            var builder = new SiloHostBuilder()
                          .UseLocalhostClustering()
                          .ConfigureServices(ConfigureServices)
                          .ConfigureApplicationParts(parts =>
                                                     parts.AddApplicationPart(typeof(SampleGrain).Assembly)
                                                     .WithReferences())
                          .AddKafkaEventBusStreams(EventBusConstants.EVENT_BUS_PROVIDER,
                                                   kafka =>
            {
                kafka.BrokerList = "vm0:9094";
            },
                                                   receiver =>
            {
                receiver.ConsumerGroup = "test";
                receiver.TopicList     = new List <string> {
                    EventBusConstants.DOMAIN_EVENT_TEST_TOPIC
                };
                receiver.TotalQueueCount = 4;
            }
                                                   )
                          .ConfigureLogging(logging => logging.AddXunit(output));

            host = builder.Build();
            await host.StartAsync();

            return(host);
        }
Esempio n. 17
0
        public void Start(ServiceArguments serviceArguments, Func <IGrainFactory, Task> afterOrleansStartup = null)
        {
            AfterOrleansStartup = afterOrleansStartup;
            _serviceArguments   = serviceArguments;

            Log.Info(_ => _("Build Bridges, Not Silos!"));
            Log.Info(_ => _("Starting Orleans silo..."));

            var builder = _orleansConfigurationBuilder.GetBuilder()
                          .UseServiceProviderFactory(o =>
            {
                _serviceProvider.ConfigureServices(o);
                return(_factoryServiceProvider());
            })
                          .ConfigureLogging(op => op.AddProvider(_logProvider))
                          .AddStartupTask(StartupTask);

            if (_orleansConfig.EnableInterceptor)
            {
                builder.AddIncomingGrainCallFilter <MicrodotIncomingGrainCallFilter>()
                .AddOutgoingGrainCallFilter(async o =>
                {
                    TracingContext.SpanStartTime = DateTimeOffset.UtcNow;
                    await o.Invoke();
                });
            }

            _siloHost = builder.Build();

            try
            {
                int cancelAfter = _serviceArguments.InitTimeOutSec ?? 60;
                var cancel      = new CancellationTokenSource(TimeSpan.FromSeconds(cancelAfter)).Token;
                var forceCancel = new CancellationTokenSource(TimeSpan.FromSeconds(cancelAfter + 10)).Token;

                _siloHost.StartAsync(cancel).Wait(forceCancel);
            }
            catch (Exception e)
            {
                throw new ProgrammaticException("Failed to start Orleans silo", unencrypted: new Tags {
                    { "siloName", CurrentApplicationInfo.HostName }
                }, innerException: e);
            }

            if (_startupTaskExceptions != null)
            {
                throw new ProgrammaticException("Failed to start Orleans silo due to an exception thrown in the bootstrap method.", unencrypted: new Tags {
                    { "siloName", CurrentApplicationInfo.HostName }
                }, innerException: _startupTaskExceptions);
            }

            Log.Info(_ => _("Successfully started Orleans silo", unencryptedTags: new { siloName = CurrentApplicationInfo.HostName }));

            _orleansConfigurator.AfterOrleansStartup(_siloHost.Services.GetService <IGrainFactory>());
            Log.Info(_ => _("afterOrleansStartup done", unencryptedTags: new { siloName = CurrentApplicationInfo.HostName }));

            HttpServiceListener.StartGettingTraffic();
            Log.Info(_ => _("start getting traffic", unencryptedTags: new { siloName = CurrentApplicationInfo.HostName }));
        }
Esempio n. 18
0
        private static async Task StartSilo()
        {
            await silo.StartAsync();

            Console.ForegroundColor = color;
            Console.WriteLine("Silo Started at {0}", DateTime.Now);
            Console.ResetColor();
        }
Esempio n. 19
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            _silo = new SiloHostBuilder()
                    .OrleansSelfhost(Configuration)
                    .Build();

            await _silo.StartAsync();
        }
Esempio n. 20
0
        private static async Task RunAsync(ISiloHost silo, IClusterClient client, string dataFilePath)
        {
            await silo.StartAsync();

            await client.Connect();

            var seedData = new SeedData(client, dataFilePath);
            await seedData.Initialise();
        }
Esempio n. 21
0
        private static async Task StartSilo()
        {
            _log.Info("Silo initialized in {timeTaken:#.##}s. Starting...", _startupStopwatch.Elapsed.TotalSeconds);
            await _siloHost.StartAsync();

            _startupStopwatch.Stop();

            _log.Info("Successfully started Silo in {timeTaken:#.##}s (total).", _startupStopwatch.Elapsed.TotalSeconds);
        }
Esempio n. 22
0
        public void OnStart()
        {
            #region 变量
            var siloPort    = SysConfig.GetAppConfig("OLSiloPort");
            var gatewayPort = SysConfig.GetAppConfig("OLGatewayPort");
            var environment = SysConfig.GetAppConfig("OLEnvironment");

            var clusterId = SysConfig.GetAppConfig("OLClusterId");
            var serviceId = SysConfig.GetAppConfig("OLServiceId");
            var logLevel  = SysConfig.GetAppConfig("OLLogLevel");
            var logPath   = SysConfig.GetAppConfig("OLlogPath");
            var DBConnStr = SysConfig.DBConnStr;

            #endregion

            ISiloHostBuilder builder = new SiloHostBuilder()
                                       .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = clusterId;
                options.ServiceId = serviceId;
            })
                                       .UseEnvironment(environment)
                                       .Configure <EndpointOptions>(options =>
            {
                options.AdvertisedIPAddress = IPAddress.Parse("192.168.2.132");
                options.GatewayPort         = int.Parse(gatewayPort);
                options.SiloPort            = int.Parse(siloPort);
            })
                                       .UseAdoNetClustering(options =>
            {
                options.ConnectionString = DBConnStr;
                options.Invariant        = "System.Data.SqlClient";
            })
                                       .ConfigureLogging(logging =>
            {
                logging.AddFile(logPath + $"\\OrleansSilos -{ DateTime.Now.ToString("yyyy.MM.dd")}.txt");
                logging.SetMinimumLevel((LogLevel)Enum.Parse(typeof(LogLevel), logLevel));
            })
                                       .ConfigureApplicationParts(parts =>
            {
                Assembly assembly = typeof(Libing.Service.UserService).Assembly;
                parts.AddApplicationPart(assembly).WithReferences();
            });

            try
            {
                Console.WriteLine("Build SiloHost.....");
                siloHost = builder.Build();
                Console.WriteLine("Async Sart SiloHost.....");
                siloHost.StartAsync().Wait();
            }
            catch (Exception ex)
            {
                Console.WriteLine("创建服务异常:" + ex.ToString());
            }
        }
Esempio n. 23
0
        private static async Task <ISiloHost> StartSilo()
        {
            var config        = LoadConfig();
            var orleansConfig = GetOrleansConfig(config);
            var builder       = new SiloHostBuilder()
                                //cluster information
                                .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = "dev";
                options.ServiceId = "HelloApp";
            }).UseLocalhostClustering()
                                //EndPoint information
                                .Configure <EndpointOptions>(option =>
            {
                option.SiloPort            = 11111;
                option.GatewayPort         = 30000;
                option.AdvertisedIPAddress = IPAddress.Loopback;
            })
                                .UseDashboard()
                                .ConfigureServices(services =>
            {
                services.AddSingleton <IOrleansRequestContext, OrleansRequestContext>();
                services.AddSingleton(s => CreateGrainMethodList());
                services.AddSingleton(s => new JsonSerializerSettings
                {
                    Formatting                 = Formatting.None,
                    TypeNameHandling           = TypeNameHandling.None,
                    ReferenceLoopHandling      = ReferenceLoopHandling.Serialize,
                    PreserveReferencesHandling = PreserveReferencesHandling.Objects
                });

                services.AddSingleton(x => CreateEventStoreConnection());
            }).AddCustomStorageBasedLogConsistencyProvider("CustomStorage")
                                .AddIncomingGrainCallFilter <LoggingFilter>()
                                .AddAdoNetGrainStorageAsDefault(options =>
            {
                options.Invariant        = orleansConfig.Invariant;
                options.ConnectionString = orleansConfig.ConnectionString;
                options.UseJsonFormat    = orleansConfig.UseJsonFormat;
            })
                                .ConfigureApplicationParts(parts =>
                                                           parts.AddApplicationPart(typeof(HelloGrain).Assembly).WithReferences())
                                .ConfigureLogging(logging =>
            {
                logging.AddFile("OrleansLog.txt");
                logging.AddDebug();
                logging.AddConsole();
            })
            ;


            _silo = builder.Build();
            await _silo.StartAsync();

            return(_silo);
        }
Esempio n. 24
0
        public async Task StartAsync()
        {
            if (_silo != null)
            {
                throw new InvalidOperationException("Host is already started");
            }

            _silo = BuildSilo();
            await _silo.StartAsync();
        }
Esempio n. 25
0
        static async Task Main(string[] args)
        {
            SetupApplicationShutdown();

            silo = CreateSilo();

            silo.StartAsync().Wait();

            _siloStopped.WaitOne();
        }
Esempio n. 26
0
        private static async Task StartSilo(string[] args)
        {
            _log.Debug("Building silo host");
            _silo = BuildSilo(args, ConfigureServices);

            _log.Information("Starting orleans silo host");
            await _silo.StartAsync();

            _log.Information("Orleans silo host started");
        }
Esempio n. 27
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            if (!stoppingToken.IsCancellationRequested)
            {
                _host = _serviceProvider.GetService <ISiloHost>();
                await _host.StartAsync();

                _logger.LogInformation("ISiloHost start");
            }
        }
Esempio n. 28
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
#if DEBUG
            host = AddLocalSiloHost();
#else
            host = AddClusteredSiloHost();
#endif

            await host.StartAsync(cancellationToken);
        }
Esempio n. 29
0
        //---------------------------------------------------------------------
        private static async Task <int> RunMainAsync()
        {
            //var ucenter_context = new UCenterContext();
            //await ucenter_context.Setup();
            //var ucenter_cfg = ucenter_context.ConfigCfg;

            SetupApplicationShutdown();

            var builder = new SiloHostBuilder()
                          .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = "a";
                options.ServiceId = "b";
            })
                          .Configure <EndpointOptions>(options =>
            {
                options.AdvertisedIPAddress = IPAddress.Loopback;
                options.GatewayPort         = 30001;
                options.SiloPort            = 11112;
            })
                          .Configure <StatisticsOptions>(options =>
            {
                options.CollectionLevel = StatisticsLevel.Critical;
            })
                          .ConfigureApplicationParts(parts =>
            {
                parts.AddApplicationPart(typeof(GrainAccount).Assembly).WithReferences();
            })
                          .ConfigureLogging(logging =>
            {
                logging.AddNLog(new NLogProviderOptions
                {
                    CaptureMessageTemplates  = true,
                    CaptureMessageProperties = true
                });
            })
                          .UseLocalhostClustering()
                          .UseSiloUnobservedExceptionsHandler()
                          .UseInMemoryReminderService()
                          .AddMemoryGrainStorageAsDefault()
                          .AddMemoryGrainStorage("PubSubStore")
                          .AddSimpleMessageStreamProvider("SMSProvider")
                          .EnableDirectClient()
                          .AddStartupTask <Startup>();

            silo = builder.Build();

            await silo.StartAsync();

            _siloStopped.WaitOne();

            await silo.StopAsync();

            return(0);
        }
Esempio n. 30
0
        static async Task RunAsync(ISiloHost silo, IClusterClient client, string mapFileName)
        {
            await silo.StartAsync();

            await client.Connect();

            var librarySetup = new LibrarySetup(client);
            await librarySetup.Configure("books.json");

            Console.WriteLine("Setup complete");
        }