Add a script to time server startup.

This commit is contained in:
Pete Chown
2022-09-14 20:02:17 +01:00
parent fdf157a3f3
commit a2d9b52c99
3 changed files with 12 additions and 2 deletions

View File

@@ -83,6 +83,6 @@ class Program
new OptionsWrapper<KestrelServerOptions>(serverOptions), transportFactory, loggerFactory); new OptionsWrapper<KestrelServerOptions>(serverOptions), transportFactory, loggerFactory);
await server.StartAsync(new Application(loggerFactory), CancellationToken.None); await server.StartAsync(new Application(loggerFactory), CancellationToken.None);
Console.ReadLine(); await Task.Delay(Timeout.Infinite);
} }
} }

View File

@@ -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. 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
```
--- ---

5
time-startup Executable file
View File

@@ -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