pub fn run_worker<'a>(
        worker_binary: &'a str,
        work_dir: &'a str,
        listen_for_commands: bool,
        config: &WorkerConfig,
        conn_str: &String,
        logger: &Logger,
    ) -> Result<Child, MeshSimError> {
        let worker_name = config.worker_name.clone();
        debug!(logger, "Starting worker process {}", &worker_name);

        let file_name = format!("{}.toml", &worker_name);
        let mut file_dir = PathBuf::new();
        file_dir.push(work_dir);
        file_dir.push(&file_name);
        debug!(logger, "Writing config file {}.", &file_dir.display());
        config.write_to_file(file_dir.as_path())?;

        //Constructing the external process call
        let child = Command::new(worker_binary)
            .env(DB_CONN_ENV_VAR, conn_str)
            .arg("--config")
            .arg(format!("{}", &file_dir.display()))
            .arg("--work_dir")
            .arg(work_dir.to_string())
            .arg("--register_worker")
            .arg(format!("{}", false))
            .arg("--accept_commands")
            .arg(format!("{}", listen_for_commands))
            .stdin(Stdio::piped())
            .stdout(Stdio::piped())
            .spawn()
            .map_err(|e| {
                let err_msg = String::from("Failed to spawn worker process");
                MeshSimError {
                    kind: MeshSimErrorKind::Master(err_msg),
                    cause: Some(Box::new(e)),
                }
            })?;
        debug!(logger, "Worker process {} started", &worker_name);

        Ok(child)
    }
/// Adds a single worker to the worker vector with a specified name and starts the worker process
Adds a single worker to the worker vector with a specified name and starts the worker process
Adds a single worker to the worker vector with a specified name and starts the worker process
pub fn run_worker<'a>(
        worker_binary: &'a str,
        work_dir: &'a str,
        listen_for_commands: bool,
        config: &WorkerConfig,
        conn_str: &String,
        logger: &Logger,
    ) -> Result<Child, MeshSimError> {
        let worker_name = config.worker_name.clone();
        debug!(logger, "Starting worker process {}", &worker_name);
        let file_name = format!("{}.toml", &worker_name);
        let mut file_dir = PathBuf::new();
        file_dir.push(work_dir);
        file_dir.push(&file_name);
        debug!(logger, "Writing config file {}.", &file_dir.display());
        config.write_to_file(file_dir.as_path())?;
        //Constructing the external process call
        let child = Command::new(worker_binary)
            .env(DB_CONN_ENV_VAR, conn_str)
            .arg("--config")
            .arg(format!("{}", &file_dir.display()))
            .arg("--work_dir")
            .arg(work_dir.to_string())
            .arg("--register_worker")
            .arg(format!("{}", false))
            .arg("--accept_commands")
            .arg(format!("{}", listen_for_commands))
            .stdin(Stdio::piped())
            .stdout(Stdio::piped())
            .spawn()
            .map_err(|e| {
                let err_msg = String::from("Failed to spawn worker process");
                MeshSimError {
                    kind: MeshSimErrorKind::Master(err_msg),
                    cause: Some(Box::new(e)),
                }
            })?;
        debug!(logger, "Worker process {} started", &worker_name);
        Ok(child)
    }
pub fn run_worker < ' a > ( worker_binary : & ' a str , work_dir : & ' a str , listen_for_commands : bool , config : & WorkerConfig , conn_str : & String , logger : & Logger , ) -> Result < Child , MeshSimError > { let worker_name = config . worker_name . clone ( ) ; debug ! ( logger " " worker_name ) ; let file_name = format ! ( " " worker_name ) ; let mut file_dir = PathBuf :: new ( ) ; file_dir . push ( work_dir ) ; file_dir . push ( & file_name ) ; debug ! ( logger " " file_dir display ( ) ) ; config . write_to_file ( file_dir . as_path ( ) ) ? ; //Constructing the external process call let child = Command :: new ( worker_binary ) . env ( DB_CONN_ENV_VAR , conn_str ) . arg ( " " ) . arg ( format ! ( " " file_dir display ( ) ) ) . arg ( " " ) . arg ( work_dir . to_string ( ) ) . arg ( " " ) . arg ( format ! ( " " false ) ) . arg ( " " ) . arg ( format ! ( " " listen_for_commands ) ) . stdin ( Stdio :: piped ( ) ) . stdout ( Stdio :: piped ( ) ) . spawn ( ) . map_err ( | e | { let err_msg = String :: from ( " " ) ; MeshSimError { kind : MeshSimErrorKind :: Master ( err_msg ) , cause : Some ( Box :: new ( e ) ) , } } ) ? ; debug ! ( logger " " worker_name ) ; Ok ( child ) }
Adds a single worker to the worker vector with a specified name and starts the worker process
Adds a single worker to the worker vector with a specified name and starts the worker process
worker_binary
&'a str
work_dir
&'a str
listen_for_commands
bool
config
&WorkerConfig
conn_str
&String
logger
&Logger