Beispiel #1
0
        public static async Task Main(string[] args)
        {
            TaskScheduler.UnobservedTaskException += (sender, e) =>
            {
                Console.WriteLine("Unobserved exception: {0}", e.Exception);
            };

            var container          = new QuickInjectContainer();
            var hostingEnvironment = new HostingEnvironment
            {
                ContentRootPath = Directory.GetCurrentDirectory()
            };

            var defaultEventSourceLoggerFactory = new DefaultEventSourceLoggerFactory();
            var startup = new Startup();

            startup.SetupQuickInjectContainer(container);
            startup.Configure(null, hostingEnvironment);

            var requestDelegate = new RequestDelegate(startup.HandleRequest);

            var server = new KestrelServer(new KestrelServerOptionsConfig(container, 5000), new SocketTransportFactory(new SocketTransportOptionsConfig(), new ApplicationLifetime(), defaultEventSourceLoggerFactory), defaultEventSourceLoggerFactory);

            await server.StartAsync(new HttpApplication(requestDelegate), CancellationToken.None);

            Thread.Sleep(Timeout.Infinite);
        }
Beispiel #2
0
        public static async Task Main(string[] args)
        {
            TaskScheduler.UnobservedTaskException += (sender, e) =>
            {
                Console.WriteLine("Unobserved exception: {0}", e.Exception);
            };

            if (args.Length != 2)
            {
                Console.WriteLine("Usage: PerfViewJS portNumber DataRoot");
                return;
            }

            string defaultAuthorizationHeaderForSourceLink = Environment.GetEnvironmentVariable("PerfViewJS_DefaultAuthorizationHeaderForSourceLink");

            var defaultEventSourceLoggerFactory = new DefaultEventSourceLoggerFactory();
            var startup = new Startup(Directory.GetCurrentDirectory(), args[1], defaultAuthorizationHeaderForSourceLink);

            var server = new KestrelServer(new KestrelServerOptionsConfig(int.Parse(args[0])), new SocketTransportFactory(new SocketTransportOptionsConfig(), defaultEventSourceLoggerFactory), defaultEventSourceLoggerFactory);

            await server.StartAsync(new HttpApplication(startup.HandleRequest), CancellationToken.None);

            Thread.Sleep(Timeout.Infinite);
        }