mod context;

use context::AppContext;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let ctx = AppContext::init()?;
    tracing::info!("email service starting");

    tokio::select! {
        result = email::EmailWorker::start(&ctx.config) => {
            if let Err(e) = result {
                tracing::error!("email worker exited with error: {}", e);
            }
        }
        _ = tokio::signal::ctrl_c() => {
            tracing::info!("shutdown signal received, stopping email service");
        }
    }

    Ok(())
}
