-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
44 lines (41 loc) · 1.56 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
using System;
using System.Threading.Tasks;
using Grpc.Core;
using Lockstep;
using Grpc.Health.V1;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
namespace MikudosLockStepGameService
{
class Program
{
public static void Main(string[] args)
{
var env = Environment.GetEnvironmentVariable("DOT_NET_ENV");
var builder = new ConfigurationBuilder();
builder
.AddYamlFile("config/appsettings.yml", optional: true)
.AddJsonFile($"config/appsettings.{env}.yml", optional: true);
IConfiguration _conf = builder.Build();
var healthService = new HealthImpl();
var lockStepService = new LockStepImpl(_conf);
int Port = _conf.GetValue<int>("port", 50051);
Server server = new Server
{
Services = {
LockStepService.BindService(lockStepService),
Health.BindService(healthService)
},
Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
};
StepService stepService = new StepService(lockStepService);
server.Start();
Console.WriteLine("Greeter server listening on port " + Port);
Console.WriteLine("Press any key to stop the server...");
var res = stepService.Start();
// res.Wait();
Console.ReadKey();
server.ShutdownAsync().Wait();
}
}
}