Skip to content

Monitoring ​

With the monitoring feature, the engine serves its event stream over gRPC. Point the Crankshaft console at it to watch tasks in a terminal, or write your own client.

Turn it on ​

The feature needs a protobuf compiler at build time. Follow the protobuf installation guide first (on macOS, brew install protobuf).

sh
cargo add crankshaft --features monitoring

Then create the engine with an address to listen on.

rust
use crankshaft::Engine;

let engine = Engine::new_with_monitoring("127.0.0.1:8080".parse()?).await;

Everything else is the same as Engine::default(). engine.shutdown() stops the server.

The monitor has no authentication

Anyone who can reach the address can see task names and cancel tasks. Bind to 127.0.0.1 unless the network in front of it is trusted.

The gRPC service ​

The service is crankshaft.monitor.Monitor, defined in crankshaft-monitor/src/proto/monitor.proto.

MethodReturnsUse it to
SubscribeEventsA stream of EventFollow the event stream live. Each message has a timestamp.
GetServiceStateEvery task and its events so farCatch up when a client connects mid-run.
CancelTask(id)NothingCancel a task by its id.

The console ​

crankshaft-console is a terminal UI in this repository. It connects to http://localhost:8080, shows every task and its latest state, and lets you cancel them.

sh
# In one terminal, run an engine with the monitor on.
cargo run --release --bin docker-monitored

# In another, from the repository root, start the console.
cargo run --release -p crankshaft-console
KeyAction
j or ↓Next task
k or ↑Previous task
tTasks view
cCancel the selected task, then y to confirm or n / Esc to back out
Ctrl+c or Ctrl+dQuit

The console always connects to port 8080 on localhost, so start the engine there.

Reference ​

Licensed MIT or Apache-2.0. Part of St. Jude Rust Labs.