};
use doku::json::{AutoComments, Formatting};
use lemmy_api::match_websocket_operation;
-use lemmy_api_common::blocking;
+use lemmy_api_common::{blocking, check_private_instance_and_federation_enabled};
use lemmy_api_crud::match_websocket_operation_crud;
use lemmy_apub_lib::activity_queue::create_activity_queue;
use lemmy_db_schema::{get_database_url_from_env, source::secret::Secret};
use lemmy_routes::{feeds, images, nodeinfo, webfinger};
-use lemmy_server::{api_routes, code_migrations::run_advanced_migrations, scheduled_tasks};
+use lemmy_server::{
+ api_routes,
+ code_migrations::run_advanced_migrations,
+ init_tracing,
+ root_span_builder::QuieterRootSpanBuilder,
+ scheduled_tasks,
+};
use lemmy_utils::{
rate_limit::{rate_limiter::RateLimiter, RateLimit},
request::build_user_agent,
};
use lemmy_websocket::{chat_server::ChatServer, LemmyContext};
use reqwest::Client;
+use reqwest_middleware::ClientBuilder;
+use reqwest_tracing::TracingMiddleware;
use std::{env, sync::Arc, thread};
use tokio::sync::Mutex;
+use tracing_actix_web::TracingLogger;
embed_migrations!();
return Ok(());
}
- env_logger::init();
+ init_tracing()?;
+
let settings = Settings::init().expect("Couldn't initialize settings.");
// Set up the r2d2 connection pool
.user_agent(build_user_agent(&settings))
.build()?;
- let activity_queue = create_activity_queue();
+ let client = ClientBuilder::new(client).with(TracingMiddleware).build();
+
+ let queue_manager = create_activity_queue(client.clone());
+
+ let activity_queue = queue_manager.queue_handle().clone();
+
+ check_private_instance_and_federation_enabled(&pool, &settings).await?;
let chat_server = ChatServer::startup(
pool.clone(),
);
let rate_limiter = rate_limiter.clone();
App::new()
- .wrap(middleware::Logger::default())
+ .wrap(actix_web::middleware::Logger::default())
+ .wrap(TracingLogger::<QuieterRootSpanBuilder>::new())
.app_data(Data::new(context))
// The routes
.configure(|cfg| api_routes::config(cfg, &rate_limiter))
.configure(|cfg| lemmy_apub::http::routes::config(cfg, &settings))
.configure(feeds::config)
- .configure(|cfg| images::config(cfg, &rate_limiter))
+ .configure(|cfg| images::config(cfg, client.clone(), &rate_limiter))
.configure(nodeinfo::config)
.configure(|cfg| webfinger::config(cfg, &settings))
})
.run()
.await?;
+ drop(queue_manager);
+
Ok(())
}