Beispiel #1
0
        private async Task RunAsync()
        {
            string ip   = "0.0.0.0";
            int    port = this._option.Port;

            var host = new RpcHostBuilder()
                       .UseServer(ip, port)
                       .UseStartup <QpsServerStartup>()
                       .Build();
            await host.StartAsync();

            Console.WriteLine("Running qps worker server on " + string.Format("{0}:{1}", ip, port));
            Console.ReadKey();
            await host.ShutdownAsync();

            Console.WriteLine("server is Shutdown");
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            NLoggerWrapper.InitConfig();
            DotBPE.Rpc.Environment.SetLogger(new NLoggerWrapper(typeof(Program)));

            var host = new RpcHostBuilder()
                       .UseStartup <Startup>()
                       .Build();

            host.StartAsync().Wait();

            Console.WriteLine("Press any key to quit!");
            Console.ReadKey();

            host.ShutdownAsync().Wait();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            //DotBPE.Rpc.Environment.SetLogger(new DotBPE.Rpc.Logging.ConsoleLogger());

            string ip   = "127.0.0.1";
            int    port = 6201;

            var host = new RpcHostBuilder()
                       .UseServer(ip, 6201)
                       .UseStartup <ServerStartup>()
                       .Build();

            host.StartAsync().Wait();
            Console.WriteLine("running server on {0}:{1}", ip, port);
            Console.WriteLine("press any key to shutdown");
            Console.ReadKey();

            host.ShutdownAsync().Wait();
            Console.WriteLine("server is shutdown");
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            DotBPE.Rpc.Environment.SetLogger(new DotBPE.Rpc.Logging.ConsoleLogger());

            // 启动HTTP服务
            var urls    = "http://127.0.0.1:6200";
            var webHost = new WebHostBuilder()
                          .UseKestrel()
                          .UseUrls(urls)
                          .UseStartup <Startup>()
                          .Build();

            webHost.StartAsync().Wait();

            Console.WriteLine("running http server listen {0}", urls);

            // RPC Server
            string ip   = "127.0.0.1";
            int    port = 6201;

            var rpcHost = new RpcHostBuilder()
                          .UseServer(ip, 6201)
                          .UseStartup <DotBPEStartup>()
                          .Build();

            rpcHost.StartAsync().Wait();
            Console.WriteLine("running server on {0}:{1}", ip, port);
            Console.WriteLine("press any key to shutdown");
            Console.ReadKey();

            webHost.StopAsync().Wait();
            Console.WriteLine("http server is shutdown");

            rpcHost.ShutdownAsync().Wait();
            Console.WriteLine("dotbpe server is shutdown");
        }
Beispiel #5
0
        public static async Task <IServerHost> StartAsync <TStartup>() where TStartup : IStartup
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            //从配置文件中 读取NLog配置
            NLoggerWrapper.InitConfig();
            //设置DotBPE内部类如何使用Logger,这里使用NLog,不配置,默认输出日志
            DotBPE.Rpc.Environment.SetLogger(new NLoggerWrapper(typeof(InteropServer)));

            // 读取json 配置
            var builder       = new ConfigurationBuilder().AddJsonFile("dotbpe.config.json");
            var configuration = builder.Build();



            // 创建Host
            var host = new RpcHostBuilder()
                       .UseConfiguration(configuration)
                       .UseStartup <TStartup>()
                       .Build();

            await host.StartAsync();

            return(host);
        }