diff --git a/Program.cs b/Program.cs index 4d039d4..cda12fc 100644 --- a/Program.cs +++ b/Program.cs @@ -83,6 +83,6 @@ class Program new OptionsWrapper(serverOptions), transportFactory, loggerFactory); await server.StartAsync(new Application(loggerFactory), CancellationToken.None); - Console.ReadLine(); + await Task.Delay(Timeout.Infinite); } } diff --git a/README.md b/README.md index a6e32f2..5656027 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,12 @@ This project demonstrates how to run Kestrel without ASP.NET. It creates a web It also demonstrates how to add the websocket middleware. If you connect to ws://localhost:8080 (with wscat, for example) it will again respond with "hello world". This time it will be sent as a textual websocket message. -I wrote this code because I was curious to see if it could be done, but it may be interesting for someone. It uses significantly less memory than ASP.NET. +I wrote this code because I was curious to see if it could be done, but it may be interesting for someone. It uses significantly less memory than ASP.NET. Startup time is a bit lower too, about 180ms on my system. On a Linux system, you can measure it like this: + +``` +dotnet publish -c Release +time ./time-startup +``` --- diff --git a/time-startup b/time-startup new file mode 100755 index 0000000..eb1bac4 --- /dev/null +++ b/time-startup @@ -0,0 +1,5 @@ +#!/bin/sh + +trap "trap exit TERM; trap EXIT; pkill --pgroup 0" INT TERM EXIT +./bin/Release/net6.0/StandaloneKestrel & +while ! curl -s http://localhost:8080; do true; done