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

source

pub fn new(options: Options) -> Process

Create new process instance

source

pub fn new_once(path: &str) -> Process

source

pub async fn version(path: &str) -> Result<Version>

source

pub fn is_running(&self) -> bool

source

pub fn mute(&self, mute: bool) -> Result<()>

source

pub fn toggle_mute(&self) -> Result<bool>

source

pub fn uptime(&self) -> Option<Duration>

source

pub fn events(&self) -> Receiver<Event>

Obtain a clone of the channel Receiver that captures Event of the underlying process.

source

pub fn replace_argv(&self, argv: Vec<String>)

source

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.

source

pub fn kill(&self) -> Result<()>

Issue a SIGKILL signal, terminating the process immediately.

source

pub fn restart(&self) -> Result<()>

Issue a SIGTERM signal causing the process to exit. The process will be restarted by the monitoring task.

source

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.

source

pub async fn join(&self) -> Result<()>

Join the process like you would a thread - this async function blocks until the process exits.

source

pub async fn stop_and_join(&self) -> Result<()>

Stop the process and block until it exits.

Trait Implementations§

source§

impl Clone for Process

source§

fn clone(&self) -> Process

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Send for Process

source§

impl Sync for Process

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

§

fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T, Global>) -> Arc<dyn Any + Send + Sync, Global>

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V