/// Starts the RTR server.
///
/// If `attached` is `false`, will fork the server and exit. Otherwise
/// just runs the server forever.
Starts the RTR server.
If `attached` is `false`, will fork the server and exit. Otherwise
just runs the server forever.
Starts the RTR server . If ` attached ` is ` false ` will fork the server and exit . Otherwise just runs the server forever .
fn rtrd(mut config: Config, attached: bool) -> Result<(), Error> {
        let repo = config.create_repository(false, true)?;
        if !attached {
            Self::daemonize(&mut config)?;
        }
        config.switch_logging(!attached)?;
        // Start out with validation so that we only fire up our sockets
        // once we are actually ready.
        if repo.update().is_err() {
            warn!("Repository update failed. Continuing anyway.");
        }
        let roas = match repo.process() {
            Ok(roas) => roas,
            Err(_) => {
                error!("Fatal: Validation failed. Aborting");
                return Err(Error)
            }
        };
        let mut metrics = Metrics::new();
        let history = OriginsHistory::new(
            AddressOrigins::from_route_origins(
                roas, &config.load_exceptions(false)?, false, &mut metrics,
            ),
            config.history_size
        );
        history.push_metrics(metrics);
        info!("Starting RTR listener...");
        let (notify, rtr) = rtr_listener(history.clone(), &config);
        let monitor = monitor_listener(history.clone(), &config);
        tokio::runtime::run(
            Self::update_future(repo, history, notify, config)
            .map_err(|_| ())
            .select(rtr).map(|_| ()).map_err(|_| ())
            .select(monitor).map(|_| ()).map_err(|_| ())
        );
        Ok(())
    }
fn rtrd ( mut config : Config , attached : bool ) -> Result < ( ) , Error > { let repo = config . create_repository ( false , true ) ? ; if ! attached { Self :: daemonize ( & mut config ) ? ; } config . switch_logging ( ! attached ) ? ; // Start out with validation so that we only fire up our sockets // once we are actually ready. if repo . update ( ) . is_err ( ) { warn ! ( " " ) ; } let roas = match repo . process ( ) { Ok ( roas ) => roas , Err ( _ ) => { error ! ( " " ) ; return Err ( Error ) } } ; let mut metrics = Metrics :: new ( ) ; let history = OriginsHistory :: new ( AddressOrigins :: from_route_origins ( roas , & config . load_exceptions ( false ) ? , false , & mut metrics , ) , config . history_size ) ; history . push_metrics ( metrics ) ; info ! ( " " ) ; let ( notify , rtr ) = rtr_listener ( history . clone ( ) , & config ) ; let monitor = monitor_listener ( history . clone ( ) , & config ) ; tokio :: runtime :: run ( Self :: update_future ( repo , history , notify , config ) . map_err ( | _ | ( ) ) . select ( rtr ) . map ( | _ | ( ) ) . map_err ( | _ | ( ) ) . select ( monitor ) . map ( | _ | ( ) ) . map_err ( | _ | ( ) ) ) ; Ok ( ( ) ) }
Starts the RTR server.
Starts the RTR server .
config
Config
attached
bool