diff options
| author | Christine Dodrill <me@christine.website> | 2021-01-02 18:11:18 -0500 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2021-01-02 18:11:27 -0500 |
| commit | 951542ccf26c1089c24100f0ff1208981979c841 (patch) | |
| tree | eed9186391e8e4f7317a15074ea9e19552aa9b5e /src | |
| parent | d63f39319397cc8d804f7642b93dd5c23636b285 (diff) | |
| download | xesite-951542ccf26c1089c24100f0ff1208981979c841.tar.xz xesite-951542ccf26c1089c24100f0ff1208981979c841.zip | |
systemdify this
Signed-off-by: Christine Dodrill <me@christine.website>
Diffstat (limited to 'src')
| -rw-r--r-- | src/build.rs | 5 | ||||
| -rw-r--r-- | src/main.rs | 21 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/build.rs b/src/build.rs index 3b73241..0d8d5a5 100644 --- a/src/build.rs +++ b/src/build.rs @@ -4,7 +4,10 @@ use std::process::Command; fn main() -> Result<()> { Ructe::from_env()?.compile_templates("templates")?; - let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap(); + let output = Command::new("git") + .args(&["rev-parse", "HEAD"]) + .output() + .unwrap(); let git_hash = String::from_utf8(output.stdout).unwrap(); println!("cargo:rustc-env=GITHUB_SHA={}", git_hash); Ok(()) diff --git a/src/main.rs b/src/main.rs index 0baaeef..0d3b1ca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate tracing; + use color_eyre::eyre::Result; use hyper::{header::CONTENT_TYPE, Body, Response}; use prometheus::{Encoder, TextEncoder}; @@ -24,7 +27,7 @@ async fn main() -> Result<()> { color_eyre::install()?; let _ = kankyo::init(); tracing_subscriber::fmt::init(); - log::info!("starting up commit {}", env!("GITHUB_SHA")); + info!("starting up commit {}", env!("GITHUB_SHA")); let state = Arc::new( app::init( @@ -161,7 +164,21 @@ async fn main() -> Result<()> { .with(warp::log(APPLICATION_NAME)) .recover(handlers::rejection); - warp::serve(site).run(([0, 0, 0, 0], 3030)).await; + if let Ok(ref mut n) = sdnotify::SdNotify::from_env() { + let _ = n + .notify_ready() + .map_err(|why| error!("can't signal readiness to systemd: {}", why)); + } + + warp::serve(site) + .run(( + [0, 0, 0, 0], + std::env::var("PORT") + .unwrap_or("3030".into()) + .parse::<u16>() + .unwrap(), + )) + .await; Ok(()) } |
