Created
October 7, 2018 17:32
-
-
Save Kritner/ffbdb25bba4f25dd4194f0d4022701d0 to your computer and use it in GitHub Desktop.
Orleans getting started part 0, server config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
public static int Main(string[] args) | |
{ | |
return RunMainAsync().Result; | |
} | |
private static async Task<int> RunMainAsync() | |
{ | |
try | |
{ | |
var host = await StartSilo(); | |
Console.WriteLine("Press Enter to terminate..."); | |
Console.ReadLine(); | |
await host.StopAsync(); | |
return 0; | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex); | |
return 1; | |
} | |
} | |
private static async Task<ISiloHost> StartSilo() | |
{ | |
// define the cluster configuration | |
var builder = new SiloHostBuilder() | |
.UseLocalhostClustering() | |
.Configure<ClusterOptions>(options => | |
{ | |
options.ClusterId = "dev"; | |
options.ServiceId = "HelloWorldApp"; | |
}) | |
.Configure<EndpointOptions>(options => options.AdvertisedIPAddress = IPAddress.Loopback) | |
.ConfigureLogging(logging => logging.AddConsole()); | |
var host = builder.Build(); | |
await host.StartAsync(); | |
return host; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More or less copied from https://github.com/dotnet/orleans/blob/master/Samples/2.0/HelloWorld/src/SiloHost/Program.cs