Program.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #endregion
  18. #region (x.x.2)加载 ServiceCenter ApiEvent BeforeCallApi
  19. var BeforeCallApi = Sers.Core.Module.Api.ApiEvent.EventBuilder.LoadEvent_BeforeCallApi(ConfigurationManager.Instance.GetByPath<JArray>("Sers.ServiceCenter.BeforeCallApi"));
  20. if (BeforeCallApi != null) Sers.ServiceCenter.ServiceCenter.Instance.apiCenterService.BeforeCallApi += BeforeCallApi;
  21. #endregion
  22. //(x.x.3)从配置文件(appsettings.json::Sers.LocalApiService.ApiLoaders ) 加载api加载器并加载api
  23. Sers.ServiceCenter.ServiceCenter.Instance.LoadApi();
  24. //(x.x.4)加载系统Api
  25. Sers.ServiceCenter.ServiceCenter.Instance.LoadSsApi(typeof(Sers.ServiceCenter.Controllers.ServiceStationController).Assembly);
  26. #endregion
  27. //(x.3) Start ServiceCenter
  28. if (!Sers.ServiceCenter.ServiceCenter.Start()) return;
  29. #region (x.4) Start gateway if needed
  30. try
  31. {
  32. GatewayHelp.Bridge();
  33. }
  34. catch (System.Exception ex)
  35. {
  36. Logger.Error(ex);
  37. return;
  38. }
  39. #endregion
  40. //(x.5) RunAwait
  41. Sers.ServiceCenter.ServiceCenter.RunAwait();
  42. }
  43. }
  44. }