1 parent
7493de6952
commit
3078ba5705
45 files changed
+2139
-1880
No files matched your search
@@ -1,8 +1,14 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::{
|
||||
bot::Bot, dedup::Dedup, event_bus::EventBus, gitea::GiteaAPI, job_queue::JobQueue,
|
||||
open_router::OpenRouterClient, sandbox::SandboxConfig, state::AppState,
|
||||
bot::{Bot, BotDeps},
|
||||
event_bus::EventBus,
|
||||
gitea::GiteaAPI,
|
||||
job_queue::JobQueue,
|
||||
open_router::OpenRouterClient,
|
||||
review_store::ReviewStore,
|
||||
sandbox::SandboxConfig,
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
use dotenvy::dotenv;
|
||||
@@ -16,7 +22,7 @@ mod bot;
|
||||
mod bot_actions;
|
||||
mod consts;
|
||||
mod db;
|
||||
mod dedup;
|
||||
mod domain;
|
||||
mod env;
|
||||
mod errors;
|
||||
mod event_bus;
|
||||
@@ -24,21 +30,29 @@ mod gitea;
|
||||
mod job_queue;
|
||||
mod metrics;
|
||||
mod open_router;
|
||||
mod review_store;
|
||||
mod sandbox;
|
||||
mod schemas;
|
||||
mod state;
|
||||
mod text;
|
||||
|
||||
/// Délai laissé aux reviews en cours et aux serveurs pour s'arrêter proprement.
|
||||
/// Time left to the running reviews and the servers to stop cleanly.
|
||||
///
|
||||
/// Sans lui, une review prise dans une sandbox récalcitrante garderait le processus
|
||||
/// en vie jusqu'à ce que le superviseur le tue.
|
||||
/// Without it, a review stuck in an unresponsive sandbox would keep the process
|
||||
/// alive until the supervisor kills it.
|
||||
const SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(60);
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
dotenv().ok();
|
||||
|
||||
// Sous-commande de migration : `steep-server migration <generate|apply|...>`.
|
||||
// TLS goes through rustls, which has no default crypto provider here: the
|
||||
// workspace compiles `ring` only, and it is installed once, for every client
|
||||
// (reqwest, sentry).
|
||||
rustls::crypto::ring::default_provider()
|
||||
.install_default()
|
||||
.map_err(|_| anyhow::anyhow!("a rustls crypto provider is already installed"))?;
|
||||
|
||||
// Migration subcommand: `steep-server migration <generate|apply|...>`.
|
||||
if std::env::args().nth(1).as_deref() == Some("migration") {
|
||||
return tokio::runtime::Runtime::new()?.block_on(run_migrations());
|
||||
}
|
||||
@@ -46,7 +60,7 @@ fn main() -> anyhow::Result<()> {
|
||||
tracing_subscriber::registry()
|
||||
.with(fmt::layer())
|
||||
.with(
|
||||
EnvFilter::try_from_default_env() // lit RUST_LOG depuis l'env
|
||||
EnvFilter::try_from_default_env() // reads RUST_LOG from the environment
|
||||
.unwrap_or_else(|_| EnvFilter::new("info")),
|
||||
)
|
||||
.init();
|
||||
@@ -124,25 +138,29 @@ async fn run() -> anyhow::Result<()> {
|
||||
);
|
||||
}
|
||||
|
||||
let db = db::connect(&config.database_url).await?;
|
||||
let dedup = Dedup::new(db.clone());
|
||||
let db = db::open(&config.database_url).await?;
|
||||
let reviews = ReviewStore::new(db.clone());
|
||||
|
||||
let queue = JobQueue::new(db);
|
||||
queue.requeue_interrupted().await?;
|
||||
|
||||
let event_bus = EventBus::new();
|
||||
|
||||
let bot = Bot::new(
|
||||
gitea_api,
|
||||
open_router_client,
|
||||
BotDeps {
|
||||
gitea: gitea_api,
|
||||
open_router: open_router_client,
|
||||
sandbox,
|
||||
reviews: reviews.clone(),
|
||||
queue: queue.clone(),
|
||||
event_bus: event_bus.clone(),
|
||||
},
|
||||
config.bot_max_concurrent,
|
||||
config.open_router_model.clone(),
|
||||
sandbox,
|
||||
dedup.clone(),
|
||||
queue.clone(),
|
||||
event_bus.clone(),
|
||||
);
|
||||
|
||||
let app_state = AppState {
|
||||
queue,
|
||||
dedup,
|
||||
reviews,
|
||||
event_bus,
|
||||
bot_name: gitea_user.login.clone(),
|
||||
config,
|
||||
|
||||
Reference in new issue
Block a user