Struct workflow_node::process::Process
source · pub struct Process { /* private fields */ }
Expand description
The Process
class facilitating execution of a Child Process in Node.js or NWJS
environments. This wrapper runs the child process as a daemon, restarting it if
it fails. The process provides stdout
and stderr
output as channel Receiver
channels, allowing for a passive capture of the process console output.
Implementations§
source§impl Process
impl Process
sourcepub fn stdout(&self) -> Receiver<String>
pub fn stdout(&self) -> Receiver<String>
Obtain a clone of the channel Receiver
that captures
stdout
output of the underlying process.
sourcepub fn stderr(&self) -> Receiver<String>
pub fn stderr(&self) -> Receiver<String>
Obtain a clone of the Receiver
that captures
stderr
output of the underlying process.
sourcepub fn run(&self) -> Result<()>
pub fn run(&self) -> Result<()>
Run the process in the background. Spawns an async task that monitors the process, capturing its output and restarting the process if it exits prematurely.
sourcepub fn restart(&self) -> Result<()>
pub fn restart(&self) -> Result<()>
Issue a SIGTERM
signal causing the process to exit. The process
will be restarted by the monitoring task.
sourcepub fn stop(&self) -> Result<()>
pub fn stop(&self) -> Result<()>
Stop the process by disabling auto-restart and issuing
a SIGTERM
signal.
sourcepub async fn join(&self) -> Result<()>
pub async fn join(&self) -> Result<()>
Join the process like you would a thread - this async function blocks until the process exits.
sourcepub async fn stop_and_join(&self) -> Result<()>
pub async fn stop_and_join(&self) -> Result<()>
Stop the process and block until it exits.
sourcepub async fn exec_with_args(
&self,
args: &[&str],
cwd: Option<PathBuf>
) -> Result<ExecutionResult>
pub async fn exec_with_args(
&self,
args: &[&str],
cwd: Option<PathBuf>
) -> Result<ExecutionResult>
Execute the process single time with custom command-line arguments.
Useful to obtain a verion via --version
or perform single-task
executions - not as a daemon.
sourcepub async fn get_version(&self) -> Result<Version>
pub async fn get_version(&self) -> Result<Version>
Obtain the process version information by running it with --version
argument.