1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-08-01 17:38:36 +00:00

remove eldrich being and install good being

This commit is contained in:
Jonathan de Jong 2021-07-04 01:18:06 +02:00
parent 9df86c2c1e
commit 14e6afc45e
34 changed files with 371 additions and 315 deletions

View file

@ -12,7 +12,7 @@ mod pdu;
mod ruma_wrapper;
mod utils;
use std::sync::Arc;
use std::{sync::{Arc, Weak}, time::{Duration, Instant}};
use database::Config;
pub use database::Database;
@ -30,10 +30,14 @@ use rocket::{
},
routes, Request,
};
use tokio::{
sync::RwLock,
time::{interval, Interval},
};
use tracing::span;
use tracing_subscriber::{prelude::*, Registry};
fn setup_rocket(config: Figment, data: Arc<Database>) -> rocket::Rocket<rocket::Build> {
fn setup_rocket(config: Figment, data: Arc<RwLock<Database>>) -> rocket::Rocket<rocket::Build> {
rocket::custom(config)
.manage(data)
.mount(
@ -201,6 +205,31 @@ async fn main() {
.await
.expect("config is valid");
{
let weak: Weak<RwLock<Database>> = Arc::downgrade(&db);
tokio::spawn(async {
let weak = weak;
let mut i = interval(Duration::from_secs(10));
loop {
i.tick().await;
if let Some(arc) = Weak::upgrade(&weak) {
log::warn!("wal-trunc: locking...");
let guard = arc.write().await;
log::warn!("wal-trunc: locked, flushing...");
let start = Instant::now();
guard.flush_wal();
log::warn!("wal-trunc: locked, flushed in {:?}", start.elapsed());
} else {
break;
}
}
});
}
if config.allow_jaeger {
let (tracer, _uninstall) = opentelemetry_jaeger::new_pipeline()
.with_service_name("conduit")