use tracing_subscriber::EnvFilter;

use photos::config::Config;
use photos::jobs;
use photos::state::AppState;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    tracing_subscriber::fmt()
        .with_env_filter(
            EnvFilter::try_from_default_env().unwrap_or_else(|_| "info,sqlx=warn".into()),
        )
        .init();

    let config = Config::from_env()?;
    let state = AppState::new(config).await?;
    jobs::run_worker(state).await;
    Ok(())
}
