Crate steward

source ·
Expand description

Task runner and process manager for Rust.

If you’re not happy managing your infrastructure with a pile of shell 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! {
          "cargo build",
          env: Env::empty(),
          pwd: Loc::root(),
          msg: "Building a server",
        }
    }

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

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

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

§Limitations

§Windows

Apparently, Windows build is broken on recent versions of Rust due to winapi being unmaintained. We need to migrate to windows-rs, but I don’t know anything about Windows, so help is very welcome!

§Async runtimes

Tokio only.

Re-exports§

Modules§

  • Base building block of the crate.
  • Dependant processes.
  • Command environment.
  • File system related types.
  • Network related types.
  • Long running processes.
  • Result and Error types of this crate.

Macros§

  • Convenience macro for creating a Cmd.
  • Formats a headline that gets printed to console when running a command.
  • Convenience macro for creating a Process.

Structs§

Traits§

  • A location of file or directory of a project.

Functions§

  • A function that prints a headline of a task and runs the task (Fn).
  • A function that prints a headline of a task and runs the task (FnMut).
  • A function that prints a headline of a task and runs the task (FnOnce).