tomaka / rouille

Web framework in Rust
Apache License 2.0
1.09k stars 105 forks source link

be able to end rouille #190

Closed mwarning closed 5 years ago

mwarning commented 5 years ago

There should be a way to end rouille. The passed closure just does blocking IO and there seems to be no way to end the thread from another thread..

brycefisher commented 5 years ago

I agree -- seems like there should be channel returned by start_server. Sending something down the transmitter end of the channel should cause the Server to stop gracefully (or ungracefully).

brycefisher commented 5 years ago

For my own tests, I've taken to simple spawning a new thread to hold the Server created by start_server. When my test function ends, the spawned thread will be shutdown...I'm not :100: sure this solution will work when I have more than exactly 1 test case.

brycefisher commented 5 years ago

Digging through issues found this: https://github.com/tomaka/rouille/issues/139#issuecomment-297480690

Basically, just call server.poll() until you want to stop the server.

mwarning commented 5 years ago

yes, but only until there is an incoming request.. Maybe you can do a dummy connection..

mwarning commented 5 years ago

ok, I will create a dummy connection to trigger the exit. Not the nicest solution. But it will probably work.