enable unix socket powers
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
adb0ebccf1
commit
a6063676d3
|
@ -2526,7 +2526,7 @@ checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
|
|||
|
||||
[[package]]
|
||||
name = "xesite"
|
||||
version = "2.2.1"
|
||||
version = "2.3.0"
|
||||
dependencies = [
|
||||
"cfcache",
|
||||
"chrono",
|
||||
|
@ -2548,7 +2548,7 @@ dependencies = [
|
|||
"pfacts",
|
||||
"pretty_env_logger",
|
||||
"prometheus",
|
||||
"rand 0.8.3",
|
||||
"rand 0.7.3",
|
||||
"reqwest",
|
||||
"ructe",
|
||||
"sdnotify",
|
||||
|
@ -2559,6 +2559,7 @@ dependencies = [
|
|||
"sitemap",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"tracing-futures",
|
||||
"tracing-subscriber",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "xesite"
|
||||
version = "2.2.1"
|
||||
version = "2.3.0"
|
||||
authors = ["Christine Dodrill <me@christine.website>"]
|
||||
edition = "2018"
|
||||
build = "src/build.rs"
|
||||
|
@ -29,6 +29,7 @@ serde_yaml = "0.8"
|
|||
sitemap = "0.4"
|
||||
thiserror = "1"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tokio-stream = { version = "0.1", features = ["net"] }
|
||||
tracing = "0.1"
|
||||
tracing-futures = "0.2"
|
||||
tracing-subscriber = { version = "0.2", features = ["fmt"] }
|
||||
|
|
36
src/main.rs
36
src/main.rs
|
@ -7,6 +7,8 @@ use prometheus::{Encoder, TextEncoder};
|
|||
use std::net::IpAddr;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use tokio::net::UnixListener;
|
||||
use tokio_stream::wrappers::UnixListenerStream;
|
||||
use warp::{path, Filter};
|
||||
|
||||
pub mod app;
|
||||
|
@ -234,18 +236,30 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
warp::serve(site)
|
||||
.run((
|
||||
IpAddr::from_str(&std::env::var("HOST").unwrap_or("::".into()))
|
||||
.expect("can't parse bindhost"),
|
||||
std::env::var("PORT")
|
||||
.unwrap_or("3030".into())
|
||||
.parse::<u16>()
|
||||
.unwrap(),
|
||||
))
|
||||
.await;
|
||||
let server = warp::serve(site);
|
||||
|
||||
Ok(())
|
||||
match std::env::var("SOCKPATH") {
|
||||
Ok(sockpath) => {
|
||||
let _ = std::fs::remove_file(&sockpath);
|
||||
let listener = UnixListener::bind(sockpath)?;
|
||||
let incoming = UnixListenerStream::new(listener);
|
||||
server.run_incoming(incoming).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Err(_) => {
|
||||
server
|
||||
.run((
|
||||
IpAddr::from_str(&std::env::var("HOST").unwrap_or("::".into()))?,
|
||||
std::env::var("PORT")
|
||||
.unwrap_or("3030".into())
|
||||
.parse::<u16>()?,
|
||||
))
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
||||
|
|
Loading…
Reference in New Issue