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 new_once(path: &str) -> Process
pub fn new_once(path: &str) -> Process
Creates a Process that runs the executable at path a single time
(no automatic restart) with default options.
Sourcepub async fn version(path: &str) -> Result<Version>
pub async fn version(path: &str) -> Result<Version>
Runs the executable at path with --version and parses the resulting Version.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true if the child process is currently running.
Sourcepub fn mute(&self, mute: bool) -> Result<()>
pub fn mute(&self, mute: bool) -> Result<()>
Enables or disables muting of the process stdout/stderr output relay.
Sourcepub fn toggle_mute(&self) -> Result<bool>
pub fn toggle_mute(&self) -> Result<bool>
Toggles muting of the process output buffer, returning the new mute state.
Sourcepub fn uptime(&self) -> Option<Duration>
pub fn uptime(&self) -> Option<Duration>
Returns how long the process has been running, or None if it is not running.
Sourcepub fn replace_argv(&self, argv: Vec<String>)
pub fn replace_argv(&self, argv: Vec<String>)
Replace the process arguments used for the next process (re)start.
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.