what's the port to listen
leoliuxd opened this issue · comments
leolau commented
use listenfd::ListenFd;
use actix_web::{server, App, Path};
fn index(info: Path<(String, u32)>) -> String {
format!("Hello {}! id:{}", info.0, info.1)
}
fn main() {
let mut listenfd = ListenFd::from_env();
let mut server = server::new(
|| App::new()
.resource("/{name}/{id}/index.html", |r| r.with(index)));
server = if let Some(listener) = listenfd.take_tcp_listener(0).unwrap() {
server.listen(listener)
} else {
server.bind("127.0.0.1:3000").unwrap()
};
server.run();
}
server.listen(listener) so what's the port ? Is is always 80?
Matt Peterson commented
The port is picked up from the systemfd command, so it's whatever you pass to the -s
flag. For example, if you do systemfd -s 80 -- ./your_server
, then it will use port 80.