Crate steward[][src]

Task runner and process manager for Rust.

If you’re not happy managing your infrastructure with a pile of bash scripts, this crate might be helpful. It provides base building blocks for defining and running various kinds of tasks. It’s like foreman but more low-level, with Rust API and more flexibility & features.

Works great with clap!

Examples

Check out runnable examples on GitHub: steward/examples.

#[macro_use]
extern crate steward;

use steward::{Cmd, Env, ProcessPool, Process};

#[tokio::main]
async fn main() -> steward::Result<()> {
    client::build_cmd().run().await?;
    server::build_cmd().run().await?;

    ProcessPool::run(vec![client::watcher(), server::watcher()]).await?;

    Ok(())
}

mod server {
    fn build_cmd() -> Cmd {
        cmd! {
          exe: "cargo build",
          env: Env::empty(),
          pwd: Loc::root(),
          msg: "Building a server",
        }
    }

    fn watcher() -> Process {
        process! {
          tag: "server",
          cmd: cmd! {
            exe: "cargo watch",
            env: Env::empty(),
            pwd: Loc::root(),
            msg: "Running a reloadable server",
          },
        }
    }
}

mod client {
    fn build_cmd() -> Cmd {
        cmd! {
          exe: "npm build",
          env: Env::empty(),
          pwd: Loc::root(),
          msg: "Building a client",
        }
    }

    fn watcher() -> Process {
        process! {
          tag: "client",
          cmd: cmd! {
            exe: "npm watch",
            env: Env::empty(),
            pwd: Loc::root(),
            msg: "Watching a client",
          },
        }
    }
}

Limitations

Async runtimes

Tokio only.

Re-exports

pub use cmd::Cmd;
pub use env::Env;
pub use process::Process;
pub use process::ProcessPool;
pub use result::Error;
pub use result::Result;

Modules

cmd

Base building block of the crate.

env

Command environment.

process

Long running process.

result

Result and Error types of this crate.

Macros

cmd

Convenience macro for creating a Cmd.

headline

Formats a headline that gets printed to console when running a command.

process

Convenience macro for creating a Process.

Traits

Location

Contains a location of file or directory of a project.