diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index 5e5b83a..6c9da05 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -3,8 +3,8 @@ use std::{path::PathBuf, sync::Arc}; | |||
| 3 | 3 | ||
| 4 | use anyhow::Result; | 4 | use anyhow::Result; |
| 5 | use tokio::signal; | 5 | use tokio::signal; |
| 6 | use tracing::{error, info, warn, Level}; | 6 | use tracing::{error, info, warn}; |
| 7 | use tracing_subscriber::FmtSubscriber; | 7 | use tracing_subscriber::{EnvFilter, FmtSubscriber}; |
| 8 | 8 | ||
| 9 | use ngit_grasp::{ | 9 | use ngit_grasp::{ |
| 10 | config::{Config, DatabaseBackend}, | 10 | config::{Config, DatabaseBackend}, |
| @@ -17,16 +17,16 @@ use ngit_grasp::{ | |||
| 17 | 17 | ||
| 18 | #[tokio::main] | 18 | #[tokio::main] |
| 19 | async fn main() -> Result<()> { | 19 | async fn main() -> Result<()> { |
| 20 | // Initialize tracing | 20 | // Load configuration first (priority: CLI flags > env vars > .env file > defaults) |
| 21 | let config = Config::load()?; | ||
| 22 | |||
| 23 | // Initialize tracing with configured log level | ||
| 21 | let subscriber = FmtSubscriber::builder() | 24 | let subscriber = FmtSubscriber::builder() |
| 22 | .with_max_level(Level::DEBUG) | 25 | .with_env_filter(EnvFilter::new(&config.log_level)) |
| 23 | .finish(); | 26 | .finish(); |
| 24 | tracing::subscriber::set_global_default(subscriber)?; | 27 | tracing::subscriber::set_global_default(subscriber)?; |
| 25 | 28 | ||
| 26 | info!("Starting ngit-grasp with nostr-relay-builder..."); | 29 | info!("Starting ngit-grasp with log level: {}", config.log_level); |
| 27 | |||
| 28 | // Load configuration (priority: CLI flags > env vars > .env file > defaults) | ||
| 29 | let config = Config::load()?; | ||
| 30 | 30 | ||
| 31 | // Validate configuration and fail fast on fatal errors | 31 | // Validate configuration and fail fast on fatal errors |
| 32 | // Recoverable issues (e.g., malformed whitelist entries) are logged as warnings | 32 | // Recoverable issues (e.g., malformed whitelist entries) are logged as warnings |
| @@ -187,8 +187,8 @@ async fn main() -> Result<()> { | |||
| 187 | )); | 187 | )); |
| 188 | 188 | ||
| 189 | // Create throttle manager for rate limiting remote git servers | 189 | // Create throttle manager for rate limiting remote git servers |
| 190 | // Default: 5 concurrent requests per domain, 30 requests per minute per domain | 190 | // Default: 5 concurrent requests per domain, 60 requests per minute per domain |
| 191 | let throttle_manager = Arc::new(ThrottleManager::new(5, 30)); | 191 | let throttle_manager = Arc::new(ThrottleManager::new(5, 60)); |
| 192 | throttle_manager.set_context(sync_ctx.clone()); | 192 | throttle_manager.set_context(sync_ctx.clone()); |
| 193 | throttle_manager.set_git_naughty_list(git_naughty_list.clone()); | 193 | throttle_manager.set_git_naughty_list(git_naughty_list.clone()); |
| 194 | 194 | ||