Files
supervisor/examples
Timur Gordon a47157aa71 fix: keep OpenRPC ServerHandle alive to prevent server shutdown
The ServerHandle was being dropped immediately after spawning, causing the
OpenRPC server to shut down. Now we properly await handle.stopped() to keep
the server running.
2025-10-27 14:34:22 +01:00
..

Hero Supervisor Examples

This directory contains examples demonstrating Hero Supervisor functionality.

Available Examples

osiris_openrpc

Comprehensive example showing the complete workflow of using Hero Supervisor with OSIRIS runners via OpenRPC.

Features:

  • Automatic supervisor and runner startup
  • OpenRPC client communication
  • Runner registration and management
  • Job dispatching with multiple scripts
  • Context-based access control
  • Graceful shutdown

Run:

cargo run --example osiris_openrpc

See osiris_openrpc/README.md for details.

Prerequisites

All examples require:

  • Redis server running on localhost:6379
  • Rust toolchain installed

Example Structure

examples/
├── README.md                    # This file
├── osiris_openrpc/             # OSIRIS + OpenRPC example
│   ├── main.rs                 # Main example code
│   ├── README.md               # Detailed documentation
│   ├── note.rhai               # Note creation script
│   ├── event.rhai              # Event creation script
│   ├── query.rhai              # Query script
│   └── access_denied.rhai      # Access control test script
└── _archive/                    # Archived old examples

Architecture Overview

The examples demonstrate the Hero Supervisor architecture:

Client (OpenRPC)
    ↓
Supervisor (OpenRPC Server)
    ↓
Redis Queue
    ↓
Runners (OSIRIS, SAL, etc.)

Development

To add a new example:

  1. Create a new directory under examples/
  2. Add main.rs with your example code
  3. Add any required script files (.rhai)
  4. Add a README.md documenting the example
  5. Update Cargo.toml to register the example
  6. Update this README with a link

Archived Examples

Previous examples have been moved to _archive/ for reference. These may be outdated but can provide useful patterns for specific use cases.