Skip to content

RFC: Add runAsDaemon option to UseHost #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joemphilips
Copy link

In my own project I wanted to start Asp.Net server from command line.
I also wanted to bind parsed CLI arguments into my option by BindCommandLine(), So I had to use UseHost(), which does not support running IHost forever and instead stops right after the startup.

I ended up re-writing my own commandline middleware which is mostly the same with UseHost ,but with one difference that it invokes host.RunAsync() instead of host.StartAsync().
So I thought it would be better to have this feature built in to this library.

Please don't merge yet, this PR has no test. I'm not even sure this is the right way to achieve my goal (I'm not super familiar to dotnet itself either).
Any feedback is welcome.

@dnfadmin
Copy link

dnfadmin commented Apr 1, 2021

CLA assistant check
All CLA requirements met.

@jonsequitur jonsequitur marked this pull request as draft April 12, 2021 17:27
if (runAsDaemon)
{
await next(invocation);
await host.RunAsync();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better using the cancellation token from the invocationContext so that we could graceful stop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants