Skip to content
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

Merged
merged 4 commits into from
Jun 8, 2019
Merged

Stoppable server #207

merged 4 commits into from
Jun 8, 2019

Conversation

rushsteve1
Copy link
Contributor

Summary

Added the Server::stoppable() function which provides a method for gracefully stopping a Server.

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.

Added the `Server::stoppable()` function
which provides a method for gracefully stopping a `Server`
Made some alterations to `Server::stoppable()` to reduce CPU load.
@rushsteve1
Copy link
Contributor Author

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.

@rushsteve1
Copy link
Contributor Author

@tomaka Are there any further issues with this? If not I would like to get it merged.

@rushsteve1
Copy link
Contributor Author

I just realized that this PR is a (better) alternative to #203

Also @tomaka again can I please get a response or something? This has been just sitting for a few weeks now.

@rushsteve1
Copy link
Contributor Author

Bumping for visibility and @tomaka once again

@tomaka
Copy link
Owner

tomaka commented Jun 8, 2019

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.
@rushsteve1
Copy link
Contributor Author

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.

@tomaka tomaka merged commit 6d21941 into tomaka:master Jun 8, 2019
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