Crate steward

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§

pub use cmd::Cmd;
pub use cmd::KillTimeout;
pub use cmd::SpawnOptions;
pub use dep::Dependency;
pub use dep::DependencyWaitError;
pub use env::Env;
pub use fs::FsEntry;
pub use net::HttpService;
pub use net::TcpService;
pub use process::PoolEntry;
pub use process::Process;
pub use process::ProcessPool;
pub use process::RunningProcess;
pub use result::Error;
pub use result::Result;

Modules§

cmd
Base building block of the crate.
dep
Dependant processes.
env
Command environment.
fs
File system related types.
net
Network related types.
process
Long running processes.
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.

Structs§

HttpMethod
The Request Method (VERB)

Traits§

Location
A location of file or directory of a project.

Functions§

print
Prints a formatted message to console.
run
A function that prints a headline of a task and runs the task (Fn).
run_mut
A function that prints a headline of a task and runs the task (FnMut).
run_once
A function that prints a headline of a task and runs the task (FnOnce).