0

我想用代码配置而不是XML文件配置来启动服务器,但是如果不调用LoadOrleansConfig方法,silo服务器就无法启动。

string providerName = "MySql.Data.MySqlClient";
string mysqlConnString = "mysqlConnString";

var config = new ClusterConfiguration();
config.Globals.DeploymentId = "OrleansTest";
config.Globals.AdoInvariant = providerName;
config.Globals.DataConnectionString = mysqlConnString;

config.Globals.LivenessType = LivenessProviderType.Custom;
config.Globals.ReminderServiceType = ReminderServiceProviderType.Custom;
config.Globals.MembershipTableAssembly = "OrleansSQLUtils";
config.Globals.ReminderTableAssembly = "OrleansSQLUtils";

config.Defaults.HostNameOrIPAddress = "localhost";
config.Defaults.Port = 11111;
config.Defaults.ProxyGatewayEndpoint = new IPEndPoint(IPAddress.Loopback, 30000);

using (var host = new SiloHost("Default"))
{
    host.Config = config;
    host.InitializeOrleansSilo();
    var result = host.StartOrleansSilo();
    Console.WriteLine("server startup {0}", result ? "successful" : "failure");
    Console.ReadLine();
    host.StopOrleansSilo();
}
4

2 回答 2

2

您不必从文件中加载配置。而不是host.Config = config;通过构造函数传递配置: https ://github.com/dotnet/orleans/blob/master/src/OrleansRuntime/Silo/SiloHost.cs#L97

于 2017-05-22T06:06:17.577 回答
0

默认情况下,启动筒仓会吞下任何异常。像这样开始,你会得到更多的信息:

var result = host.StartOrleansSilo(catchExceptions: false);

在这种情况下,您会得到:

“由于先前的初始化错误,无法启动 silo 默认值”

那是你不知道的。要解决此问题,请像这样设置您的 SiloHost:

using (var host = new SiloHost("Default", config))
于 2017-06-07T13:24:14.813 回答