//! FIFA 17 UTAS migration host entrypoint.
//!
//! Serves `GET …/club` from OpenFUT Core and proxies every other UTAS route to
//! the Python oracle. Config is env-only (see [`openfut_utas_host::config`]);
//! bind and Python upstream are required with no default.

use openfut_utas_host::{config::HostConfig, Server};

fn main() {
    let cfg = match HostConfig::from_env() {
        Ok(c) => c,
        Err(e) => {
            eprintln!("utas-host config error: {e}");
            std::process::exit(2);
        }
    };
    eprintln!(
        "utas-host starting: listen={} python_upstream={} core_url={} tables_dir={} catalog={} identity_store={} persona_id={}",
        cfg.listen_addr, cfg.python_upstream, cfg.core_url, cfg.tables_dir, cfg.catalog_path, cfg.identity_store_path, cfg.persona_id
    );
    let server = match Server::from_config(&cfg) {
        Ok(s) => s,
        Err(e) => {
            eprintln!("utas-host startup error: {e}");
            std::process::exit(1);
        }
    };
    if let Err(e) = server.serve(&cfg.listen_addr) {
        eprintln!("utas-host serve error: {e}");
        std::process::exit(1);
    }
}
