signal systemd readiness
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
580bca120a
commit
b0a15936a9
|
@ -1240,6 +1240,7 @@ dependencies = [
|
|||
"rocket_prometheus",
|
||||
"rusty_ulid",
|
||||
"scraper",
|
||||
"sdnotify",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
|
@ -2266,6 +2267,12 @@ dependencies = [
|
|||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sdnotify"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71ce7eac2075a4562fbcbad544cd55d72ebc760e0a5594a7c8829cf2b4b42a7a"
|
||||
|
||||
[[package]]
|
||||
name = "selectors"
|
||||
version = "0.22.0"
|
||||
|
|
|
@ -25,6 +25,7 @@ rocket_cors = "0.5"
|
|||
rocket_prometheus = "0.7.0"
|
||||
rusty_ulid = "0.10"
|
||||
scraper = "0.12.0"
|
||||
sdnotify = { version = "0.1", default-features = false }
|
||||
serde_json = "^1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
thiserror = "1"
|
||||
|
|
|
@ -6,7 +6,7 @@ extern crate rocket;
|
|||
extern crate tracing;
|
||||
|
||||
use color_eyre::eyre::Result;
|
||||
use rocket::http::Method;
|
||||
use rocket::{fairing::AdHoc, http::Method};
|
||||
use rocket_contrib::helmet::SpaceHelmet;
|
||||
use rocket_cors::{AllowedHeaders, AllowedOrigins};
|
||||
use rocket_prometheus::PrometheusMetrics;
|
||||
|
@ -58,6 +58,13 @@ fn main() -> Result<()> {
|
|||
.attach(PluralKit::fairing())
|
||||
.attach(SwitchCounter::fairing())
|
||||
.attach(Twitter::fairing())
|
||||
.attach(AdHoc::on_launch("systemd readiness", |_| {
|
||||
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));
|
||||
}
|
||||
}))
|
||||
.mount("/metrics", prometheus)
|
||||
.mount("/", routes![botinfo])
|
||||
.mount(
|
||||
|
|
|
@ -37,6 +37,7 @@ let
|
|||
export DATABASE_URL=./mi.db
|
||||
export ROCKET_DATABASES='{ main_data = { url = "./mi.db" } }';
|
||||
${composite}/bin/migrate_database
|
||||
${composite}/bin/bridgy_migrate
|
||||
export ROCKET_ASSET_PATH=${composite}/public
|
||||
exec ${composite}/bin/mi
|
||||
'';
|
||||
|
|
Loading…
Reference in New Issue