Program.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Newtonsoft.Json.Linq;
  2. using Sers.Gateway;
  3. using Vit.Core.Module.Log;
  4. using Vit.Core.Util.ConfigurationManager;
  5. using Vit.Extensions;
  6. namespace App.ServiceCenter
  7. {
  8. public class Program
  9. {
  10. public static void Main(string[] args)
  11. {
  12. //(x.1) Init
  13. Sers.ServiceCenter.ServiceCenter.Init();
  14. #region (x.2) 初始化扩展模块
  15. #region (x.x.1)使用 Gover 服务治理 模块
  16. Sers.ServiceCenter.ServiceCenter.Instance.UseGover();
  17. Sers.Gover.Base.GoverManage.Instance.UseZipkin();
  18. #endregion
  19. #region (x.x.2)加载 ServiceCenter ApiEvent BeforeCallApi
  20. var BeforeCallApi = Sers.Core.Module.Api.ApiEvent.EventBuilder.LoadEvent_BeforeCallApi(ConfigurationManager.Instance.GetByPath<JArray>("Sers.ServiceCenter.BeforeCallApi"));
  21. if (BeforeCallApi != null) Sers.ServiceCenter.ServiceCenter.Instance.apiCenterService.BeforeCallApi += BeforeCallApi;
  22. #endregion
  23. //(x.x.3)从配置文件(appsettings.json::Sers.LocalApiService.ApiLoaders ) 加载api加载器并加载api
  24. Sers.ServiceCenter.ServiceCenter.Instance.LoadApi();
  25. //(x.x.4)加载系统Api
  26. Sers.ServiceCenter.ServiceCenter.Instance.LoadSsApi(typeof(Sers.ServiceCenter.Controllers.ServiceStationController).Assembly);
  27. #endregion
  28. //(x.3) Start ServiceCenter
  29. if (!Sers.ServiceCenter.ServiceCenter.Start()) return;
  30. #region (x.4) Start gateway if needed
  31. try
  32. {
  33. GatewayHelp.Bridge();
  34. }
  35. catch (System.Exception ex)
  36. {
  37. Logger.Error(ex);
  38. return;
  39. }
  40. #endregion
  41. //(x.5) RunAwait
  42. Sers.ServiceCenter.ServiceCenter.RunAwait();
  43. }
  44. }
  45. }