From 9d6a3fe41ae9e0a628a080ac21c5a57042096fbe Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 11 Jul 2018 14:58:54 +0800 Subject: [PATCH] add port support --- src/server/MagCore.Server/Program.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/server/MagCore.Server/Program.cs b/src/server/MagCore.Server/Program.cs index cc4fa1b..b504563 100644 --- a/src/server/MagCore.Server/Program.cs +++ b/src/server/MagCore.Server/Program.cs @@ -19,11 +19,22 @@ public static void Main(string[] args) } public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) + WebHost.CreateDefaultBuilder(new string[] { }) .UseStartup() .UseKestrel(options => { - options.Listen(IPAddress.Any, 6000); + if (args.Any(g => g.Trim().ToLower().Contains("-port="))) + { + string arg = args.SingleOrDefault(g => g.Trim().ToLower().Contains("-port=")); + string sPort = arg.ToLower().Trim().Replace("-port=", string.Empty); + if (Int32.TryParse(sPort, out int port)) + { + options.Listen(IPAddress.Any, port); + } + } + else + options.Listen(IPAddress.Any, 6000); + }) .Build(); }