public static void Main(string[] args) { var procs = Environment.ProcessorCount; ThreadPool.SetMaxThreads(procs, Math.Max(1, procs / 4)); ThreadPool.SetMaxThreads(procs * 2, Math.Max(1, procs / 2)); LoggingProvider.Use(LoggingProvider.ConsoleLoggingProvider); var config = ConfigManager.Load <ServerConfig>(); var server = new HttpBackend(IPAddress.Any, config.ListenPort); var wsService = new WebSocketService(); var staticWebContentFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "web"); var routeTable = new RouteTable( Route.Get("/*").With(new DirectoryInfo(staticWebContentFolder)), Route.Get("/").With(wsService.Redirect), Route.Get("/plaintext").With(() => greeting), Route.Get("/plaintext/delayed").WithAsync(DelayedGreeter), Route.GetWebSocketUpgrade("/ws").With(wsService.HandleUpgradeRequest), Route.Get("/metrics").With(Lift.ToJsonHandler(server.GetMetricsReport)) .ApplyResponseFilter(Filters.GZip) .LimitRate(100) ); server.Start(routeTable); }
public static void Main(string[] args) { var procs = Environment.ProcessorCount; ThreadPool.SetMaxThreads(procs, Math.Max(1, procs / 4)); ThreadPool.SetMaxThreads(procs * 2, Math.Max(1, procs / 2)); LoggingProvider.Use(LoggingProvider.ConsoleLoggingProvider); var config = ConfigManager.Load<ServerConfig>(); var server = new HttpBackend(IPAddress.Any, config.ListenPort); var wsService = new WebSocketService(); var staticWebContentFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "web"); var routeTable = new RouteTable( Route.Get("/*").With(new DirectoryInfo(staticWebContentFolder)), Route.Get("/").With(wsService.Redirect), Route.Get("/plaintext").With(() => greeting), Route.Get("/plaintext/delayed").WithAsync(DelayedGreeter), Route.GetWebSocketUpgrade("/ws").With(wsService.HandleUpgradeRequest), Route.Get("/metrics").With(Lift.ToJsonHandler(server.GetMetricsReport)) .ApplyResponseFilter(Filters.GZip) .LimitRate(100) ); server.Start(routeTable); }