-
Notifications
You must be signed in to change notification settings - Fork 106
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
Stoppable server #207
Stoppable server #207
Conversation
Added the `Server::stoppable()` function which provides a method for gracefully stopping a `Server`
Made some alterations to `Server::stoppable()` to reduce CPU load.
As @LPGhatguy pointed out it was consuming a lot of CPU. I fixed that with c1256a4 As it stands on my machine the system monitor reports 0% CPU usage when idle and ~50% when under heavy synthetic load. The only caveat is that there is at most 1 second between checks to see if the stop has been requested. There is no delay between server responses however. I believe that 1s can be lowered but I thought it was a good conservative delay. Linked here is a simple project with a synthetic benchmark for testing purposes. |
@tomaka Are there any further issues with this? If not I would like to get it merged. |
Bumping for visibility and @tomaka once again |
Well, I pushed a commit to your branch that updates it over master. But I screwed up by breaking the example, and now I don't have the authorization to push to your branch anymore. Sorry about that. |
The test had been broken so this fixes it.
I updated it to fix the test, but now some random macro breaks on the old version of Rust you have it testing against so the CI fails. |
Summary
Added the
Server::stoppable()
function which provides a method for gracefully stopping aServer
.Motivation
There was obvious way to gracefully stop a Rouille server, and I ended up implementing this code in my own project. Since it's fairly simple and a useful feature I figured I would contribute it back.
See the provided documentation example for basic usage.