pub fn new(config_file: Option<String>) -> Self {
        // initialize metrics
        crate::metrics::init();

        // load config from file
        let config = if let Some(file) = config_file {
            debug!("loading config: {}", file);
            match PingserverConfig::load(&file) {
                Ok(c) => Arc::new(c),
                Err(e) => {
                    error!("{}", e);
                    std::process::exit(1);
                }
            }
        } else {
            Arc::new(Default::default())
        };

        // initialize admin
        let admin = Admin::new(config.clone()).unwrap_or_else(|e| {
            error!("{}", e);
            std::process::exit(1);
        });

        // initialize worker
        let worker = Worker::new(config.clone()).unwrap_or_else(|e| {
            error!("{}", e);
            std::process::exit(1);
        });

        // initialize server
        let server = Server::new(config, worker.session_sender()).unwrap_or_else(|e| {
            error!("{}", e);
            std::process::exit(1);
        });

        Self {
            admin,
            server,
            worker,
        }
    }
/// Creates a new `PingserverBuilder` with an optional config file.
///
/// This function will terminate the program execution if there are any
/// issues encountered while initializing the components.
Creates a new `PingserverBuilder` with an optional config file.
This function will terminate the program execution if there are any
issues encountered while initializing the components.
Creates a new ` PingserverBuilder ` with an optional config file . This function will terminate the program execution if there are any issues encountered while initializing the components .
pub fn new(config_file: Option<String>) -> Self {
        // initialize metrics
        crate::metrics::init();
        // load config from file
        let config = if let Some(file) = config_file {
            debug!("loading config: {}", file);
            match PingserverConfig::load(&file) {
                Ok(c) => Arc::new(c),
                Err(e) => {
                    error!("{}", e);
                    std::process::exit(1);
                }
            }
        } else {
            Arc::new(Default::default())
        };
        // initialize admin
        let admin = Admin::new(config.clone()).unwrap_or_else(|e| {
            error!("{}", e);
            std::process::exit(1);
        });
        // initialize worker
        let worker = Worker::new(config.clone()).unwrap_or_else(|e| {
            error!("{}", e);
            std::process::exit(1);
        });
        // initialize server
        let server = Server::new(config, worker.session_sender()).unwrap_or_else(|e| {
            error!("{}", e);
            std::process::exit(1);
        });
        Self {
            admin,
            server,
            worker,
        }
    }
pub fn new ( config_file : Option < String > ) -> Self { // initialize metrics crate :: metrics :: init ( ) ; // load config from file let config = if let Some ( file ) = config_file { debug ! ( " " file ) ; match PingserverConfig :: load ( & file ) { Ok ( c ) => Arc :: new ( c ) , Err ( e ) => { error ! ( " " e ) ; std :: process :: exit ( 1 ) ; } } } else { Arc :: new ( Default :: default ( ) ) } ; // initialize admin let admin = Admin :: new ( config . clone ( ) ) . unwrap_or_else ( | e | { error ! ( " " e ) ; std :: process :: exit ( 1 ) ; } ) ; // initialize worker let worker = Worker :: new ( config . clone ( ) ) . unwrap_or_else ( | e | { error ! ( " " e ) ; std :: process :: exit ( 1 ) ; } ) ; // initialize server let server = Server :: new ( config , worker . session_sender ( ) ) . unwrap_or_else ( | e | { error ! ( " " e ) ; std :: process :: exit ( 1 ) ; } ) ; Self { admin , server , worker , } }
Creates a new `PingserverBuilder` with an optional config file.
Creates a new ` PingserverBuilder ` with an optional config file .
config_file
Option<String>
config_file
Option<String>