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
pub fn new_once(path: &str) -> Process
pub async fn version(path: &str) -> Result<Version>
pub fn is_running(&self) -> bool
pub fn mute(&self, mute: bool) -> Result<()>
pub fn toggle_mute(&self) -> Result<bool>
pub fn uptime(&self) -> Option<Duration>
pub fn replace_argv(&self, argv: Vec<String>)
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. Returns Ok(())
if the process
is not running.
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.