feat: simplify OpenRPC API and reorganize examples
- Simplified RunnerConfig to just name, command, and optional env - Removed RunnerType and ProcessManagerType enums - Removed db_path, redis_url, binary_path from config - Made runner name also serve as queue name (no separate queue param) - Added secret-based authentication to all runner management methods - Created comprehensive osiris_openrpc example - Archived old examples to _archive/ - Updated client API to match simplified supervisor interface
This commit is contained in:
268
MYCELIUM_OPTIONAL.md
Normal file
268
MYCELIUM_OPTIONAL.md
Normal file
@@ -0,0 +1,268 @@
|
||||
# Mycelium Integration - Now Optional!
|
||||
|
||||
The Mycelium integration is now an optional feature. The supervisor can run with just the OpenRPC HTTP server, making it simpler to use and deploy.
|
||||
|
||||
## What Changed
|
||||
|
||||
### Before
|
||||
- Mycelium integration was always enabled
|
||||
- Supervisor would continuously try to connect to Mycelium on port 8990
|
||||
- Error logs if Mycelium wasn't available
|
||||
- Required additional dependencies
|
||||
|
||||
### After
|
||||
- ✅ Mycelium is now an optional feature
|
||||
- ✅ Supervisor runs with clean OpenRPC HTTP server by default
|
||||
- ✅ No connection errors when Mycelium isn't needed
|
||||
- ✅ Smaller binary size without Mycelium dependencies
|
||||
|
||||
## Running the Supervisor
|
||||
|
||||
### Option 1: Simple OpenRPC Server (Recommended)
|
||||
|
||||
**No Mycelium, just OpenRPC:**
|
||||
|
||||
```bash
|
||||
# Using the helper script
|
||||
./run_supervisor_simple.sh
|
||||
|
||||
# Or manually
|
||||
MYCELIUM_URL="" cargo run --bin supervisor -- \
|
||||
--redis-url redis://localhost:6379 \
|
||||
--port 3030
|
||||
```
|
||||
|
||||
This starts:
|
||||
- ✅ OpenRPC HTTP server on port 3030
|
||||
- ✅ Redis connection for job queuing
|
||||
- ❌ No Mycelium integration
|
||||
|
||||
### Option 2: With Mycelium Integration
|
||||
|
||||
**Enable Mycelium feature:**
|
||||
|
||||
```bash
|
||||
# Build with Mycelium support
|
||||
cargo build --bin supervisor --features mycelium
|
||||
|
||||
# Run with Mycelium URL
|
||||
MYCELIUM_URL="http://localhost:8990" cargo run --bin supervisor --features mycelium -- \
|
||||
--redis-url redis://localhost:6379 \
|
||||
--port 3030
|
||||
```
|
||||
|
||||
This starts:
|
||||
- ✅ OpenRPC HTTP server on port 3030
|
||||
- ✅ Redis connection for job queuing
|
||||
- ✅ Mycelium integration (connects to daemon)
|
||||
|
||||
## Feature Flags
|
||||
|
||||
### Available Features
|
||||
|
||||
| Feature | Description | Default |
|
||||
|---------|-------------|---------|
|
||||
| `cli` | Command-line interface | ✅ Yes |
|
||||
| `mycelium` | Mycelium integration | ❌ No |
|
||||
|
||||
### Building with Features
|
||||
|
||||
```bash
|
||||
# Default build (CLI only, no Mycelium)
|
||||
cargo build --bin supervisor
|
||||
|
||||
# With Mycelium
|
||||
cargo build --bin supervisor --features mycelium
|
||||
|
||||
# Minimal (no CLI, no Mycelium)
|
||||
cargo build --bin supervisor --no-default-features
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
### Without Mycelium (Default)
|
||||
|
||||
```
|
||||
┌─────────────────┐
|
||||
│ Client │
|
||||
└────────┬────────┘
|
||||
│ HTTP/JSON-RPC
|
||||
▼
|
||||
┌─────────────────┐
|
||||
│ Supervisor │
|
||||
│ OpenRPC Server │
|
||||
│ (Port 3030) │
|
||||
└────────┬────────┘
|
||||
│ Redis
|
||||
▼
|
||||
┌─────────────────┐
|
||||
│ Runners │
|
||||
└─────────────────┘
|
||||
```
|
||||
|
||||
### With Mycelium (Optional)
|
||||
|
||||
```
|
||||
┌─────────────────┐
|
||||
│ Client │
|
||||
└────────┬────────┘
|
||||
│ HTTP/JSON-RPC
|
||||
▼
|
||||
┌─────────────────┐ ┌──────────────┐
|
||||
│ Supervisor │◄────►│ Mycelium │
|
||||
│ OpenRPC Server │ │ Daemon │
|
||||
│ (Port 3030) │ │ (Port 8990) │
|
||||
└────────┬────────┘ └──────────────┘
|
||||
│ Redis
|
||||
▼
|
||||
┌─────────────────┐
|
||||
│ Runners │
|
||||
└─────────────────┘
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Description | Default | Required |
|
||||
|----------|-------------|---------|----------|
|
||||
| `MYCELIUM_URL` | Mycelium daemon URL | `http://127.0.0.1:8990` | No |
|
||||
| `RUST_LOG` | Log level | `info` | No |
|
||||
|
||||
**To disable Mycelium:**
|
||||
```bash
|
||||
export MYCELIUM_URL=""
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
### Core Dependencies (Always)
|
||||
- `tokio` - Async runtime
|
||||
- `redis` - Job queuing
|
||||
- `jsonrpsee` - OpenRPC server
|
||||
- `runner_rust` - Job model
|
||||
|
||||
### Mycelium Dependencies (Optional)
|
||||
- `reqwest` - HTTP client
|
||||
- `base64` - Encoding
|
||||
- `rand` - Random IDs
|
||||
|
||||
## Examples
|
||||
|
||||
All examples work without Mycelium:
|
||||
|
||||
```bash
|
||||
# Simple end-to-end example
|
||||
RUST_LOG=info cargo run --example simple_e2e
|
||||
|
||||
# Full automated demo
|
||||
RUST_LOG=info cargo run --example end_to_end_demo
|
||||
```
|
||||
|
||||
## Migration Guide
|
||||
|
||||
### If you were using Mycelium
|
||||
|
||||
**Before:**
|
||||
```bash
|
||||
cargo run --bin supervisor
|
||||
# Would try to connect to Mycelium automatically
|
||||
```
|
||||
|
||||
**After:**
|
||||
```bash
|
||||
# Option A: Disable Mycelium (recommended for most use cases)
|
||||
MYCELIUM_URL="" cargo run --bin supervisor
|
||||
|
||||
# Option B: Enable Mycelium feature
|
||||
cargo run --bin supervisor --features mycelium
|
||||
```
|
||||
|
||||
### If you weren't using Mycelium
|
||||
|
||||
**Before:**
|
||||
```bash
|
||||
cargo run --bin supervisor
|
||||
# Would see connection errors to port 8990
|
||||
```
|
||||
|
||||
**After:**
|
||||
```bash
|
||||
cargo run --bin supervisor
|
||||
# Clean startup, no connection errors! 🎉
|
||||
```
|
||||
|
||||
## Benefits
|
||||
|
||||
### For Development
|
||||
- ✅ Faster builds (fewer dependencies)
|
||||
- ✅ Simpler setup (no Mycelium daemon needed)
|
||||
- ✅ Cleaner logs (no connection errors)
|
||||
- ✅ Easier debugging
|
||||
|
||||
### For Production
|
||||
- ✅ Smaller binary size
|
||||
- ✅ Fewer runtime dependencies
|
||||
- ✅ More flexible deployment
|
||||
- ✅ Optional advanced features
|
||||
|
||||
## Testing
|
||||
|
||||
### Test without Mycelium
|
||||
```bash
|
||||
# Build
|
||||
cargo build --bin supervisor
|
||||
|
||||
# Run tests
|
||||
cargo test
|
||||
|
||||
# Run examples
|
||||
cargo run --example simple_e2e
|
||||
```
|
||||
|
||||
### Test with Mycelium
|
||||
```bash
|
||||
# Build with feature
|
||||
cargo build --bin supervisor --features mycelium
|
||||
|
||||
# Start Mycelium daemon (if you have one)
|
||||
# mycelium-daemon --port 8990
|
||||
|
||||
# Run supervisor
|
||||
MYCELIUM_URL="http://localhost:8990" cargo run --bin supervisor --features mycelium
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Mycelium integration not enabled"
|
||||
|
||||
This is informational, not an error. If you need Mycelium:
|
||||
|
||||
```bash
|
||||
cargo build --features mycelium
|
||||
```
|
||||
|
||||
### "HTTP request failed: error sending request"
|
||||
|
||||
If you see this with Mycelium enabled, check:
|
||||
1. Is Mycelium daemon running?
|
||||
2. Is the URL correct? (`MYCELIUM_URL`)
|
||||
3. Is the port accessible?
|
||||
|
||||
Or simply disable Mycelium:
|
||||
```bash
|
||||
export MYCELIUM_URL=""
|
||||
```
|
||||
|
||||
## Summary
|
||||
|
||||
🎉 **The supervisor now runs cleanly with just OpenRPC!**
|
||||
|
||||
- Default: OpenRPC HTTP server only
|
||||
- Optional: Enable Mycelium with `--features mycelium`
|
||||
- No more connection errors when Mycelium isn't needed
|
||||
- Simpler, faster, cleaner!
|
||||
|
||||
---
|
||||
|
||||
**Status:** ✅ Complete
|
||||
**Version:** 0.1.0
|
||||
**Last Updated:** 2025-10-24
|
||||
Reference in New Issue
Block a user