예제 #1
0
파일: AppManager.cs 프로젝트: jclown/test
        public static void RegisterServices(this IServiceCollection services, List <string> registerList)
        {
            // 本地api注册到服务中心
            var registerService = ConfigManager.Configuration["ServiceConfig:RegisterService"];

            if (!string.IsNullOrEmpty(registerService))
            {
                try
                {
                    var discovery = GetServiceFromRoot <Modobay.Discovery.IDiscoveryServer>();
                    var reg       = new Regex(registerService);
                    foreach (var item in _apiInterfaceTypes.Select(x => x.FullName).ToList())
                    {
                        if (reg.IsMatch(item))
                        {
                            registerList.Add(item);
                        }
                    }
                    var keep = discovery.Register(ServiceAddress.Replace(":", "_"), registerList);
                    // todo pxg 暂时屏蔽
                    Schedule.ScheduleManager.CreateJob <Modobay.Discovery.KeepServiceScheduleJob>($"0/{keep} * * * * ? *");
                }
                catch (Exception ex) { Lib.Log.WriteExceptionLog($"AppManager.AddServices:{ex.Message}  <br> StackTrace:{ex.StackTrace}"); }
            }
        }