/// <summary> /// 入口 /// </summary> /// <param name="args"></param> /// <returns></returns> public static async Task Main(string[] args) { Console.Title = $"{ConfigCenterConfig.ServerInfo.Name} 版本:[{ApplicationConfig.GetProgramVersion()}]"; string[] inputArgs = MateralAPPHelper.HandlerArgs(args, ConfigCenterConfig.ServerInfo); ConfigCenterConsoleHelper.WriteLine($"本服务地址:{ApplicationConfig.Url}"); ConfigCenterConsoleHelper.WriteLine($"本服务公开地址:{ApplicationConfig.PublicUrl}"); await CreateHostBuilder(inputArgs).Build().RunAsync(); }
public Task RegisterResult(bool isSuccess, string message) { if (isSuccess) { ConfigCenterConsoleHelper.WriteLine("注册成功"); } else { ConfigCenterConsoleHelper.WriteLine(message, "注册失败", ConsoleColor.Red); } return(Task.CompletedTask); }
public void RegisterEnvironment(string key, RegisterEnvironmentModel model) { (bool canRegister, string errorMessage) = CanRegister(key, model); if (!canRegister) { throw new ConfigCenterException(errorMessage); } if (_registers.TryAdd(key, model)) { ConfigCenterConsoleHelper.WriteLine($"新的环境[{model.Name}]注册:{model.Url}"); } else { throw new ConfigCenterException("注册服务失败"); } }
public void UnRegisterEnvironment(string key) { if (!_registers.ContainsKey(key)) { return; } while (true) { if (!_registers.TryRemove(key, out RegisterEnvironmentModel register)) { continue; } if (register != null) { ConfigCenterConsoleHelper.WriteLine($"环境[{register.Name}]已断开:{register.Url}"); } break; } }