mirror of
https://github.com/actix/actix-website
synced 2025-06-29 08:14:58 +02:00
Updates 'autoreloading' section
This commit is contained in:
@ -40,33 +40,7 @@ listenfd = "0.3"
|
||||
|
||||
Then modify your server code to only invoke `bind` as a fallback:
|
||||
|
||||
```rust
|
||||
extern crate actix_web;
|
||||
extern crate listenfd;
|
||||
|
||||
use listenfd::ListenFd;
|
||||
use actix_web::{server, App, HttpRequest, Responder};
|
||||
|
||||
fn index(_req: &HttpRequest) -> impl Responder {
|
||||
"Hello World!"
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut listenfd = ListenFd::from_env();
|
||||
let mut server = server::new(|| {
|
||||
App::new()
|
||||
.resource("/", |r| r.f(index))
|
||||
});
|
||||
|
||||
server = if let Some(l) = listenfd.take_tcp_listener(0).unwrap() {
|
||||
server.listen(l)
|
||||
} else {
|
||||
server.bind("127.0.0.1:3000").unwrap()
|
||||
};
|
||||
|
||||
server.run();
|
||||
}
|
||||
```
|
||||
{{< include-example example="autoreload" file="main.rs" section="autoreload" >}}
|
||||
|
||||
## Running the Server
|
||||
|
||||
|
Reference in New Issue
Block a user