My Silo Host project Program.cs
Main method looks like below,
private static async Task Main(string[] args)
{
int siloPort, gatewayPort;
try
{
siloPort = int.Parse(args[0]);
gatewayPort = int.Parse(args[1]);
}
catch (Exception)
{
siloPort = 11111;
gatewayPort = 30000;
}
var invariant = "System.Data.SqlClient"; // for Microsoft SQL Server
var connectionString = "Data Source=.;Initial Catalog=OrleansCluster;Integrated Security=True;Pooling=False;Max Pool Size=200;MultipleActiveResultSets=True";
var siloBuilder = new SiloHostBuilder()
// Clustering information
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "dev";
options.ServiceId = "ServiceApp";
})
.UseAdoNetClustering(options =>
{
options.Invariant = invariant;
options.ConnectionString = connectionString;
})
.ConfigureEndpoints(siloPort: siloPort, gatewayPort: gatewayPort)
.ConfigureLogging(logging => logging.AddConsole());
using (var host = siloBuilder.Build())
{
await host.StartAsync();
Console.ReadLine();
}
}
To run multiple Silo, we need to specify different set of ports for each. Here we are achieving the same via parsing the args.
Now you can run a Silo by executing following command on the Silo project root directory
dotnet run <siloPort> <gatewayPort>
eg,
dotnet run 11111 30000
dotnet run 11112 30001
dotnet run 11113 30002