aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2021-01-09 17:16:30 -0500
committerGitHub <noreply@github.com>2021-01-09 17:16:30 -0500
commit1bd858680de4bb9dc3ffaa274eb93aec56012a0f (patch)
treef848e33e66f54d4b93f5eb2a0aebed6745a70e07 /src/main.rs
parent49a4d7cbeaeb2bf7b9870a0a01af69253f22e6bf (diff)
downloadxesite-1bd858680de4bb9dc3ffaa274eb93aec56012a0f.tar.xz
xesite-1bd858680de4bb9dc3ffaa274eb93aec56012a0f.zip
Borgbackup nixos post (#291)
* fix the systemd notify code Signed-off-by: Christine Dodrill <me@christine.website> * remove k8s baktag Signed-off-by: Christine Dodrill <me@christine.website> * borg backup post Signed-off-by: Christine Dodrill <me@christine.website> * fix build Signed-off-by: Christine Dodrill <me@christine.website>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 0d3b1ca..c05ac49 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -39,6 +39,21 @@ async fn main() -> Result<()> {
.await?,
);
+ match sdnotify::SdNotify::from_env() {
+ Ok(ref mut n) => {
+ n.notify_ready().map_err(|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
+ })?;
+ }
+ Err(why) => error!("not running under systemd with Type=notify: {}", why),
+ }
+
let healthcheck = warp::get().and(warp::path(".within").and(warp::path("health")).map(|| "OK"));
let base = warp::path!("blog" / ..);
@@ -164,12 +179,6 @@ async fn main() -> Result<()> {
.with(warp::log(APPLICATION_NAME))
.recover(handlers::rejection);
- 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],