Ejemplo n.º 1
0
 /// <summary>
 /// 健康检查
 /// </summary>
 /// <param name="configServer"></param>
 private async Task HealthAsync(ConfigServerModel configServer)
 {
     try
     {
         await _configServerRepository.HealthAsync(configServer.Address);
     }
     catch (Exception)
     {
         _configServers.Remove(configServer.Name, out ConfigServerModel client);
         var ex = new MateralConfigCenterException($"健康检查失败,配置服务{client.Name}({client.Address})已注销,当前配置服务数量{_configServers.Count}");
         ConsoleHelper.ServerWriteError(ex);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 健康检查定时器
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void HealthTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     healthTimer.Stop();
     Task.Run(async() =>
     {
         try
         {
             await _configServerRepository.HealthAsync();
             if (!healthTimer.Enabled)
             {
                 healthTimer.Start();
             }
         }
         catch (Exception ex)
         {
             ex = new MateralConfigCenterException("Protal健康检查失败", ex);
             ConsoleHelper.ServerWriteError(ex);
             Register();
         }
     });
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 注册定时器
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void RegisterTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     registerTimer.Stop();
     Task.Run(async() =>
     {
         try
         {
             ConsoleHelper.ServerWriteLine($"开始向Protal注册服务{ApplicationConfig.ProtalServerConfig.Name}");
             await _configServerRepository.RegisterAsync();
             ConsoleHelper.ServerWriteLine("注册成功");
             if (!healthTimer.Enabled)
             {
                 healthTimer.Start();
             }
         }
         catch (Exception ex)
         {
             ex = new MateralConfigCenterException("注册失败", ex);
             ConsoleHelper.ServerWriteError(ex);
             Register();
         }
     });
 }