private static void Main(string[] args) { //MonitorTest test = new MonitorTest("test"); //test.MyMutex.WaitOne(); //Console.Write("测试"); //Console.ReadLine(); ContainerBuilder containerBuilder = new ContainerBuilder(); IServiceHostServerBuilder builder = new ServiceHostServerBuilder(containerBuilder) .LoadServices("Lamp.Service.Test") .UseRpcForTransfer(8007) .UseConsulCheckHealth(new RegisterServer("127.0.0.1", 8500)) .UseValidation() .UseJwtForOAuth(new JwtAuthorizationOptions { ServerIp = "127.0.0.1", ServerPort = 8007, SecretKey = "test", ExpireTimeSpan = new TimeSpan(1, 0, 0), TokenEndpointPath = "/base/token", ValidateLifetime = true, CheckCredential = o => { if (o.UserName == "admin" && o.Password == "admin") { o.AddClaim("department", "IT部"); } else { o.Rejected("401", "acount or password incorrect"); } } }); //.UseInServerForDiscovery(); try { using (Core.IServiceHost host = builder.Build()) { host.Run(); Console.ReadLine(); } } catch (Exception e) { Console.Write(e); Console.ReadLine(); } }
//public static Mutex mutex = new Mutex(); private static void Main(string[] args) { //MonitorTest test = new MonitorTest("test1"); //test.MyMutex.WaitOne(); //Console.Write(AppDomain.CurrentDomain.BaseDirectory); //Console.ReadLine(); ContainerBuilder containerBuilder = new ContainerBuilder(); IServiceHostServerBuilder builder = new ServiceHostServerBuilder(containerBuilder) .LoadServices("Lamp.Service.Test", "Lamp.Service.Test1") .UseRpcForTransfer(8008) .UseConsulCheckHealth(new RegisterServer("127.0.0.1", 8500)) .LoadConifg("appsettings.json").UseValidation(); //.UseInServerForDiscovery(); using (Core.IServiceHost host = builder.Build()) { host.Run(); Console.ReadLine(); } }