Startup.cs 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Serilog;
  2. namespace AipGateway.AIP.Service
  3. {
  4. public class Startup
  5. {
  6. public static void SetSystemConfig()
  7. {
  8. ThreadPool.GetAvailableThreads(out int workerThreads1, out int completionPortThreads1);
  9. ThreadPool.GetMaxThreads(out int workerThreads2, out int completionPortThreads2);
  10. ThreadPool.GetMinThreads(out int workerThreads3, out int completionPortThreads3);
  11. Log.Information(" AvailableThreads: worker({0}), port({1})", workerThreads1, completionPortThreads1);
  12. Log.Information(" MaxThreads: worker({0}), port({1})", workerThreads2, completionPortThreads2);
  13. Log.Information(" MinThreads: worker({0}), port({1})", workerThreads3, completionPortThreads3);
  14. Log.Information(" UseNagleAlgorithm: {0}", System.Net.ServicePointManager.UseNagleAlgorithm);
  15. System.Net.ServicePointManager.UseNagleAlgorithm = false;
  16. Log.Information(" UseNagleAlgorithm: {0}, Application Set.", System.Net.ServicePointManager.UseNagleAlgorithm);
  17. Log.Information(" Expect100Continue: {0}", System.Net.ServicePointManager.Expect100Continue);
  18. System.Net.ServicePointManager.Expect100Continue = false;
  19. Log.Information(" Expect100Continue: {0}, Application Set.", System.Net.ServicePointManager.Expect100Continue);
  20. Log.Information(" CheckCertificateRevocationList: {0}", System.Net.ServicePointManager.CheckCertificateRevocationList);
  21. System.Net.ServicePointManager.CheckCertificateRevocationList = true;
  22. Log.Information(" CheckCertificateRevocationList: {0}, Application Set.", System.Net.ServicePointManager.CheckCertificateRevocationList);
  23. Log.Information("DefaultPersistentConnectionLimit: {0}", System.Net.ServicePointManager.DefaultPersistentConnectionLimit);
  24. Log.Information(" DefaultConnectionLimit: {0}", System.Net.ServicePointManager.DefaultConnectionLimit);
  25. System.Net.ServicePointManager.DefaultConnectionLimit = 2048;
  26. Log.Information(" DefaultConnectionLimit: {0}, Application Set.", System.Net.ServicePointManager.DefaultConnectionLimit);
  27. // Bump up the min threads reserved for this app to ramp connections faster - minWorkerThreads defaults to 4, minIOCP defaults to 4
  28. ThreadPool.SetMinThreads(100, 100);
  29. // Change max connections from .NET to a remote service default: 2
  30. //System.Net.ServicePointManager.DefaultConnectionLimit = 65000;
  31. // Turn off the Expect 100 to continue message - 'true' will cause the caller to wait until it round-trip confirms a connection to the server
  32. //System.Net.ServicePointManager.Expect100Continue = false;
  33. // Can decrease overall transmission overhead but can cause delay in data packet arrival
  34. //System.Net.ServicePointManager.UseNagleAlgorithm = false;
  35. }
  36. public static bool AipFileInitialize(AipFileManager aipFileManager)
  37. {
  38. if (!aipFileManager.Initialize())
  39. {
  40. Log.Error("AipFileInitialize, aipFileManager.Initialize Failed, {0}, {1}", aipFileManager.LastErrNo, aipFileManager.LastErrMsg);
  41. return false;
  42. }
  43. if (!aipFileManager.CreateProfile())
  44. {
  45. Log.Error("AipFileInitialize, aipFileManager.CreateProfile Failed, {0}, {1}", aipFileManager.LastErrNo, aipFileManager.LastErrMsg);
  46. return false;
  47. }
  48. if (!aipFileManager.CreateEngine())
  49. {
  50. Log.Error("AipFileInitialize, aipFileManager.CreateEngine Failed, {0}, {1}", aipFileManager.LastErrNo, aipFileManager.LastErrMsg);
  51. return false;
  52. }
  53. return true;
  54. }
  55. }
  56. }