Comments (8)
A callback on success would allow further actions, like launching an embedded browser to connect to the resulting listening port (if a port was picked by the system instead the Config).
from rocket.
Would a Rocket::launch() -> Result
still block on success?
I ask because, if so, I'd suggest for a slightly lower-level interface to be exposed as well. That'd allow framework users to start tasks after successful binds, for instance.
We could keep launch
but also expose optional separate bind and run loop methods, say, countdown
and takeoff
. Well, substituting those tongue-in-cheek names but you get the idea. π
Thoughts? Also, how could a Rust newbie help?
from rocket.
Yes, launch
should block. It is consistent with how other web servers work (iron, nickel) and besides, how would we make it not block? Make Rocket run launch
in a thread? That seems like it would create its own set of issues.
I like the idea of separating bind and run loop, if it would be possible to bind to multiple ports and addresses (possibly with different http/s combinations) and then handle connections from all with a single run loop, that would be amazing. However, I am not sure if it is even possible. AFAIK iron cannot do that, not sure if hyper can.
from rocket.
I ask because, if so, I'd suggest for a slightly lower-level interface to be exposed as well. That'd allow framework users to start tasks after successful binds, for instance.
This case is solved by #210 (still a work in progress)
from rocket.
I think we can be a tad-bit more clever here, but I agree. Let's get this in for 0.3.
from rocket.
An interesting hack would be to make ::launch()
use a new thread to start the server and then .join()
it in the Drop (which I think is default for rust's threads).
Your normal examples would all work the same but something like this would also work:
fn main() {
// ignore the obvious port conflict here
let _ = rocket::ignite().launch();
let _ = rocket::ignite().launch();
}
Yes, launch should block. It is consistent with how other web servers work (iron, nickel) and besides, how would we make it not block?
Iron does not block. At least it doesn't in the current version. I'm guessing it uses a similar approach to what I say above.
from rocket.
Someone (maybe you?) proposed this, but it just feels like too much magic. I had in mind something much simpler: return a RocketError
where RocketError
implements Drop
and simply prints the error out to the console. This exactly emulates the behavior we have right now, and the behavior most will want, while still letting someone catch it.
from rocket.
I can't imagine myself ever wanting multiple rocket servers running from the same main so don't want it that much. It's super easy to have N binaries in the same cargo project anyway.
I'm fine with the simpler option.
from rocket.
Related Issues (20)
- how to return error as a Json from FromParam HOT 3
- Responder enums not serializing like expected HOT 1
- FileServer can serve pre-gzipped content if it exists on the filesystem HOT 1
- Cookies aren't read by get methods but it exists in the browser HOT 2
- HTTP3/QUIC support HOT 15
- Add HTMLStream HOT 5
- cookie removal and Microsoft Edge HOT 7
- Inject script to auto-reload browser when Rocket restarts
- Rocket App Hangs HOT 5
- DefaultListener::bindable() isnβt usable HOT 8
- Allow routes that match any method HOT 4
- Hyper and Rocket disagreeing on validity of URL HOT 3
- Allow from form macro to work on structs with range HOT 4
- Clippy Lint w/ FromForm derive HOT 7
- Possible Incompleteness HOT 1
- Possible Incompleteness HOT 1
- doc: change `&ContentType` with `&Accept` in the list of implementations of `FromRequest` HOT 1
- [Feature]: Enhanced State Mutation for Effortless Handling of Shared Resources HOT 5
- Guide navigation causes relative links inside articles to 404 HOT 1
- Redirection to a route which takes a vector parameter results in an error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rocket.