Skip to content

Is there something like IIS recycling periodically for Kestrel server on Linux? #40147

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

Closed
vladimir-cheverdyuk-altium opened this issue Feb 11, 2022 · 9 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved

Comments

@vladimir-cheverdyuk-altium

I re-read all documentation of how to host ASP.NET website on Linux and in all cases it is Apache or nginx that just forwards traffic to Kestrel server that is running as service.

But is there any way to recycle ASP.NET periodically on Linux? Or shutdown web suite when it is idle and start on first request?

I can restart service by timer, but it will affect requests it is processing and for some time (few seconds) new requests will not be processed.

Thank you,
Vlad

@adityamandaleeka
Copy link
Member

If you need to periodically restart Kestrel, you'd need to use an orchestrator to do it; there's no built-in support for that type of thing in Kestrel.

Similarly, while you could write some code that would shut down the server when it's idle, you'd need something external to start it again when a request comes in.

@adityamandaleeka adityamandaleeka added the ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. label Feb 11, 2022
@ghost ghost added the Status: Resolved label Feb 11, 2022
@vladimir-cheverdyuk-altium
Copy link
Author

Do you know any such orchestrator by any chance?

@davidfowl
Copy link
Member

davidfowl commented Feb 12, 2022

Systemd on Linux with socket activation

@vladimir-cheverdyuk-altium
Copy link
Author

Thank you @davidfowl. Do you know by any chance, does ASP.NET supports it? I had mixed results when searched internet.
Also do you know, will it work with periodic recycling? I meant if I restart service, will it finish with current requests and then restart my service and then process new requests?

Thank you,
Vlad

@davidfowl
Copy link
Member

Thank you @davidfowl. Do you know by any chance, does ASP.NET supports it?

Yes. https://www.nuget.org/packages/Microsoft.Extensions.Hosting.Systemd/ and UseSystemd to enable socket activation for Kesterl.

Also do you know, will it work with periodic recycling?

I have no idea. That's a systemd questions.

I meant if I restart service, will it finish with current requests and then restart my service and then process new requests?

It should, the system is designed with graceful shutdown in mind but I don't know how systemd handles the creation of a new process after draining the existing one.

@davidfowl
Copy link
Member

@davidfowl
Copy link
Member

Three's also PM2 https://pm2.keymetrics.io/ (it says node js but it's a generic process monitor)

@vladimir-cheverdyuk-altium
Copy link
Author

Thank up @davidfowl. It looks like systemd with socket activation is all I need. I still need to do some testing but it looks promising from documentation. Once I get results I will post them here.

@ghost
Copy link

ghost commented Feb 14, 2022

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Feb 14, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 16, 2022
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 25, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved
Projects
None yet
Development

No branches or pull requests

5 participants