Program.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using Nancy.Hosting.Event2;
  3. using Nancy;
  4. using System.Threading;
  5. namespace LibeventHost
  6. {
  7. internal class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. var host = args[0];
  12. var port = int.Parse(args[1]);
  13. var dbHost = args[2];
  14. LibLocator.Init();
  15. NancyBenchmark.DbModule.MYSQL_CONNECTION_STRING = "server=localhost;user id=benchmarkdbuser;password=benchmarkdbpass;database=hello_world"
  16. .Replace("localhost", dbHost);
  17. AddToIndex();
  18. var threads = 20*Environment.ProcessorCount;
  19. ThreadPool.SetMaxThreads(threads, threads);
  20. ThreadPool.SetMinThreads(threads, threads);
  21. new NancyEvent2Host(host, port, new DefaultNancyBootstrapper()).Start();
  22. }
  23. private static void AddToIndex()
  24. {
  25. Nancy.Bootstrapper.AppDomainAssemblyTypeScanner
  26. .AddAssembliesToScan(typeof (NancyBenchmark.JsonModule).Assembly);
  27. }
  28. }
  29. }