-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Program.cs
64 lines (56 loc) · 1.83 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Orleans.Hosting;
using GPSTracker;
using System.Net;
await Host.CreateDefaultBuilder(args)
.UseOrleans((ctx, siloBuilder) =>
{
// In order to support multiple hosts forming a cluster, they must listen on different ports.
// Use the --InstanceId X option to launch subsequent hosts.
var instanceId = ctx.Configuration.GetValue<int>("InstanceId");
siloBuilder.UseLocalhostClustering(
siloPort: 11111 + instanceId,
gatewayPort: 30000 + instanceId,
primarySiloEndpoint: new IPEndPoint(IPAddress.Loopback, 11111));
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.ConfigureKestrel((ctx, kestrelOptions) =>
{
// To avoid port conflicts, each Web server must listen on a different port.
var instanceId = ctx.Configuration.GetValue<int>("InstanceId");
kestrelOptions.ListenLocalhost(5001 + instanceId);
});
})
.ConfigureServices((ctx, services) =>
{
services.AddHostedService<HubListUpdater>();
})
.RunConsoleAsync();
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddSignalR().AddJsonProtocol();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseDefaultFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<LocationHub>("/locationHub");
});
}
}