aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2021-01-16 21:38:22 -0500
committerChristine Dodrill <me@christine.website>2021-01-16 21:38:22 -0500
commit4bcc848bb178d9e4372ba13b750d620cabc2a9ac (patch)
treee2a97a5a03c934de6307b3d543d5f4b249675ce7 /src/main.rs
parent17af42bc698237d1560b8add144641ae3950b469 (diff)
downloadxesite-4bcc848bb178d9e4372ba13b750d620cabc2a9ac.tar.xz
xesite-4bcc848bb178d9e4372ba13b750d620cabc2a9ac.zip
move poking services into app boot after systemd notify
Signed-off-by: Christine Dodrill <me@christine.website>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/main.rs b/src/main.rs
index 285bb93..91cd12b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -39,21 +39,6 @@ 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" / ..);
@@ -222,6 +207,28 @@ async fn main() -> Result<()> {
.with(warp::log(APPLICATION_NAME))
.recover(handlers::rejection);
+ match sdnotify::SdNotify::from_env() {
+ Ok(ref mut n) => {
+ // shitty heuristic for detecting if we're running in prod
+ tokio::spawn(async {
+ if let Err(why) = app::poke::the_cloud().await {
+ error!("Unable to poke the cloud: {}", why);
+ }
+ });
+
+ 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),
+ }
+
warp::serve(site)
.run((
[0, 0, 0, 0],