Smeltery
Get started

Digging deeper

v0.1

Console commands

The app binary runs these commands (the smeltery command forwards them):

Command Does
serve start the HTTP server (the default), with the app's Watchfire agents, queue workers and scheduler (--no-agents: without them)
work run the Watchfire agents, queue workers and scheduler without the HTTP server
route:list list every route
migrate, migrate:rollback, migrate:fresh, migrate:status migrations (see above)
db:seed run the seeders
cache:clear [store] remove every entry of the default cache store, or of the named one, except Watchfire's leases and schedule claims (--all: those too)
agents:list the running app's agents with state, health, restarts, runs, last heartbeat, next restart
agents:start, agents:stop, agents:pause, agents:resume, agents:restart <name> control an agent of the running app
agents:logs <name> an agent's last log lines, from the running app
agents:token print the Watchfire API token (derived from APP_KEY) for other API clients
agents:runs <name> an agent's latest runs from the database (--limit N, default 20)
schedule:list the scheduled tasks with their next run
schedule:run run the scheduled tasks due this minute once (for system cron)
help list every command, the app's own included

An app adds its own in app/commands/, registered in app/commands/mod.rs and wired with .commands(app::commands::register):

rust
use smeltery::console::{Args, Command, Commands};
use smeltery::{App, Result};

pub struct Greet;

impl Command for Greet {
    fn name(&self) -> &'static str {
        "greet"
    }

    fn about(&self) -> &'static str {
        "Say hello"
    }

    async fn run(&self, app: &App, args: Args) -> Result<()> {
        println!("Hello, {}!", args.get(0).unwrap_or("world"));
        Ok(())
    }
}

pub fn register(c: &mut Commands) {
    c.add(Greet);
    // smeltery:commands
}

Args gives positional words with args.get(0), flags with args.flag("force") and values with args.value("step") (--step 2 or --step=2). An option followed by a word that does not start with - takes it as its value, so flags go after positional words (greet Ada --loud). A built-in command's name always runs the built-in.

↑↓ moveEnter openEsc close