private static void Main() { while (true) { Console.WriteLine("请输入配置文件名称:"); var configName = Console.ReadLine(); var configFile = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{Path.GetFileNameWithoutExtension(configName)}.xml")); if (!configFile.Exists) { Console.WriteLine($"配置文件:{configFile.FullName},不存在!"); continue; } Console.WriteLine("请输入节点名称:"); var nodeName = Console.ReadLine() ?? string.Empty; using (var host = new SiloHost(nodeName, configFile)) { host.LoadOrleansConfig(); host.InitializeOrleansSilo(); host.StartOrleansSilo(); Console.WriteLine("已启动,按下任意键退出。"); Console.ReadLine(); host.StopOrleansSilo(); } break; } }
private static void Run() { var config = GetClusterConfiguration(); config.Globals.SeedNodes.Add(new IPEndPoint(IPAddress.Loopback, 11111)); config.Defaults.HostNameOrIPAddress = "localhost"; config.Defaults.Port = 11111; config.Defaults.ProxyGatewayEndpoint = new IPEndPoint(IPAddress.Loopback, 12345); var process = Process.GetCurrentProcess(); var name = Environment.MachineName + "_" + process.Id + Guid.NewGuid().ToString("N").Substring(3); var silo = new SiloHost(name, config); // Configure the silo for the current environment. silo.SetSiloType(Silo.SiloType.Primary); Trace.TraceInformation("Silo configuration: \n" + silo.Config.ToString(name)); silo.InitializeOrleansSilo(); Trace.TraceInformation("Successfully initialized Orleans silo '{0}' as a {1} node.", silo.Name, silo.Type); Trace.TraceInformation("Starting Orleans silo '{0}' as a {1} node.", silo.Name, silo.Type); if (silo.StartOrleansSilo()) { silo.WaitForOrleansSiloShutdown(); } }
public bool Run() { bool ok = false; try { siloHost.InitializeOrleansSilo(); ok = siloHost.StartOrleansSilo(); if (ok) { Console.WriteLine(string.Format("Successfully started Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type)); } else { throw new SystemException(string.Format("Failed to start Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type)); } } catch (Exception exc) { siloHost.ReportStartupError(exc); var msg = string.Format("{0}:\n{1}\n{2}", exc.GetType().FullName, exc.Message, exc.StackTrace); Console.WriteLine(msg); } return(ok); }
static void Main(string[] args) { var config = new Orleans.Runtime.Configuration.ClusterConfiguration(); config.LoadFromFile("Host.xml"); //SiloHost siloHost = new SiloHost(System.Net.Dns.GetHostName()); //初始化一个silohost,这里使用了Orleans提供的silohost而不是silo,其中silo的名字命名为Ba; Orleans.Runtime.Host.SiloHost siloHost = new Orleans.Runtime.Host.SiloHost("Ba", config); //初始化仓储 siloHost.InitializeOrleansSilo(); //启动 siloHost.StartOrleansSilo(); //检查一下 if (siloHost.IsStarted) { Console.WriteLine("silohost 启动成功"); } else { Console.WriteLine("启动失败"); } Console.ReadKey(); //关闭silo siloHost.StopOrleansSilo(); //未初始化这个silo (搞不懂啥意思) siloHost.UnInitializeOrleansSilo(); //优雅的关闭这个silo siloHost.ShutdownOrleansSilo(); Console.ReadKey(); }
static void InitSilo(string[] args) { siloHost = new SiloHost(System.Net.Dns.GetHostName()); // The Cluster config is quirky and weird to configure in code, so we're going to use a config file siloHost.ConfigFileName = "OrleansConfiguration.xml"; siloHost.InitializeOrleansSilo(); var startedok = siloHost.StartOrleansSilo(); if (!startedok) throw new SystemException(String.Format("Failed to start Orleans silo '{0}' as a {1} node", siloHost.Name, siloHost.Type)); }
private static void InitSilo(string[] args) { siloHost=new SiloHost(System.Net.Dns.GetHostName()); siloHost.ConfigFileName = "OrleansConfiguration.xml"; siloHost.InitializeOrleansSilo(); var startedOk = siloHost.StartOrleansSilo(); if (!startedOk) { throw new SystemException(String.Format("Failed to start Orleans silo '{0}' as a {1} node", siloHost.Name, siloHost.Type)); } }
private static void Main(string[] args){ using (SiloHost host = new SiloHost("Default")){ host.LoadOrleansConfig(); host.InitializeOrleansSilo(); host.StartOrleansSilo(); Console.WriteLine("Start--------"); Console.ReadLine(); host.StopOrleansSilo(); } }
static void InitSilo(string[] args) { siloHost = new SiloHost(System.Net.Dns.GetHostName()); // possible from code, but easier via config siloHost.ConfigFileName = "OrleansConfiguration.xml"; siloHost.InitializeOrleansSilo(); var startedok = siloHost.StartOrleansSilo(); if (!startedok) { throw new SystemException(String.Format("Failed to start silo '{0}' as '{1}' node", siloHost.Name, siloHost.Type)); } }
static void InitSilo(string[] args) { _siloHost = new SiloHost(Dns.GetHostName()) { ConfigFileName = "ServerConfiguration.xml" }; _siloHost.InitializeOrleansSilo(); var startedOk = _siloHost.StartOrleansSilo(); if (!startedOk) throw new SystemException($"Failed to start Orleans silo '{_siloHost.Name}' as a {_siloHost.Type} node"); }
private bool StartSilo() { logger.Info(ErrorCode.Runtime_Error_100292, "Starting Orleans silo '{0}' as a {1} node.", host.Name, host.Type); bool ok = host.StartOrleansSilo(); if (ok) { logger.Info(ErrorCode.Runtime_Error_100293, "Successfully started Orleans silo '{0}' as a {1} node.", host.Name, host.Type); } else { logger.Error(ErrorCode.Runtime_Error_100285, string.Format("Failed to start Orleans silo '{0}' as a {1} node.", host.Name, host.Type)); } return(ok); }
private static void InitSilo(string[] args) { _host = new SiloHost(Dns.GetHostName()) { ConfigFileName = "OrleansConfiguration.xml" }; _host.LoadOrleansConfig(); _host.InitializeOrleansSilo(); if (_host.StartOrleansSilo()) { Console.WriteLine($"Started host {_host.Name} as a {_host.Type} node"); } else { Console.WriteLine($"Failed to start host {_host.Name}"); } }
private static void InitSilo(string[] args) { var configFile = Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location) , "OrleansConfiguration.xml"); _host = new SiloHost(Dns.GetHostName()) { ConfigFileName = configFile }; _host.LoadOrleansConfig(); _host.InitializeOrleansSilo(); if (_host.StartOrleansSilo()) { Console.WriteLine($"Started host {_host.Name} as a {_host.Type} node"); } else { Console.WriteLine($"Failed to start host {_host.Name}"); } }
private static void InitSilo(String[] args) { Common.initConsoleLog(); siloHost = new SiloHost(Dns.GetHostName()) { ConfigFileName = "OrleansConfiguration.xml" }; siloHost.InitializeOrleansSilo(); if (!siloHost.StartOrleansSilo()) { throw new Exception( $"Failed to start Orleans silo '{siloHost.Name}' " + $"as a {siloHost.Type} node" ); } }
static void Main(string[] args) { while (true) { Console.WriteLine("请输入配置文件名称:"); var configName = Console.ReadLine(); configName = string.IsNullOrEmpty(configName) ? "OrleansConfiguration" : configName; var configFile = new FileInfo( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format("{0}.xml", configName))); if (!configFile.Exists) { Console.WriteLine("配置文件:{0} 不存在", configFile.Name); continue; } Console.WriteLine("请输入节点名称"); var nodeName = Console.ReadLine() ?? string.Empty; using (var host = new SiloHost(nodeName, configFile)) { host.LoadOrleansConfig(); host.InitializeOrleansSilo(); host.StartOrleansSilo(); Console.WriteLine("已启动,按下任意键退出"); Console.ReadLine(); host.StopOrleansSilo(); } } //AppDomain hostDomain=AppDomain.CreateDomain("OrleansHost",null,new AppDomainSetup() //{ // AppDomainInitializer =InitSilo //}); //DoSomeClientWork(); //Console.WriteLine("Orleans Silo is running.\nPress Enter to terminate..."); //Console.ReadLine(); //hostDomain.DoCallBack(ShutdownSilo); }