forked from cadey/xesite
fix production
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
c51ffae976
commit
dd445722fe
|
@ -45,7 +45,7 @@ mi = { path = "./lib/mi" }
|
||||||
patreon = { path = "./lib/patreon" }
|
patreon = { path = "./lib/patreon" }
|
||||||
|
|
||||||
# os-specific dependencies
|
# os-specific dependencies
|
||||||
[target.'cfg(linux)'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
sdnotify = { version = "0.1", default-features = false }
|
sdnotify = { version = "0.1", default-features = false }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
39
src/main.rs
39
src/main.rs
|
@ -207,29 +207,30 @@ async fn main() -> Result<()> {
|
||||||
.with(warp::log(APPLICATION_NAME))
|
.with(warp::log(APPLICATION_NAME))
|
||||||
.recover(handlers::rejection);
|
.recover(handlers::rejection);
|
||||||
|
|
||||||
#[cfg(linux)]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
match sdnotify::SdNotify::from_env() {
|
match sdnotify::SdNotify::from_env() {
|
||||||
Ok(ref mut n) => {
|
Ok(ref mut n) => {
|
||||||
// shitty heuristic for detecting if we're running in prod
|
// shitty heuristic for detecting if we're running in prod
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {
|
||||||
if let Err(why) = app::poke::the_cloud().await {
|
if let Err(why) = app::poke::the_cloud().await {
|
||||||
error!("Unable to poke the cloud: {}", why);
|
error!("Unable to poke the cloud: {}", why);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
n.notify_ready().map_err(|why| {
|
n.notify_ready().map_err(|why| {
|
||||||
error!("can't signal readiness to systemd: {}", why);
|
error!("can't signal readiness to systemd: {}", why);
|
||||||
why
|
|
||||||
})?;
|
|
||||||
n.set_status(format!("hosting {} posts", state.clone().everything.len()))
|
|
||||||
.map_err(|why| {
|
|
||||||
error!("can't signal status to systemd: {}", why);
|
|
||||||
why
|
why
|
||||||
})?;
|
})?;
|
||||||
|
n.set_status(format!("hosting {} posts", state.clone().everything.len()))
|
||||||
|
.map_err(|why| {
|
||||||
|
error!("can't signal status to systemd: {}", why);
|
||||||
|
why
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
Err(why) => error!("not running under systemd with Type=notify: {}", why),
|
||||||
}
|
}
|
||||||
Err(why) => error!("not running under systemd with Type=notify: {}", why),
|
}
|
||||||
}}
|
|
||||||
|
|
||||||
warp::serve(site)
|
warp::serve(site)
|
||||||
.run((
|
.run((
|
||||||
|
|
Loading…
Reference in New Issue