refactor wip
This commit is contained in:
185
core/supervisor/examples/cli/README.md
Normal file
185
core/supervisor/examples/cli/README.md
Normal file
@@ -0,0 +1,185 @@
|
||||
# Hero Supervisor CLI Example
|
||||
|
||||
This example demonstrates how to use the `hive-supervisor` CLI tool for managing workers and jobs in the Hero ecosystem.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. **Redis Server**: Make sure Redis is running on `localhost:6379`
|
||||
```bash
|
||||
# Install Redis (macOS)
|
||||
brew install redis
|
||||
|
||||
# Start Redis
|
||||
redis-server
|
||||
```
|
||||
|
||||
2. **Zinit Process Manager**: Install and configure Zinit
|
||||
```bash
|
||||
# Install Zinit (example for Linux/macOS)
|
||||
# Follow Zinit installation instructions for your platform
|
||||
```
|
||||
|
||||
3. **Worker Binaries**: The configuration references worker binaries that need to be available:
|
||||
- `/usr/local/bin/osis_worker`
|
||||
- `/usr/local/bin/sal_worker`
|
||||
- `/usr/local/bin/v_worker`
|
||||
- `/usr/local/bin/python_worker`
|
||||
|
||||
For testing purposes, you can create mock worker binaries or update the paths in `config.toml` to point to existing binaries.
|
||||
|
||||
## Configuration
|
||||
|
||||
The `config.toml` file contains the supervisor configuration:
|
||||
|
||||
- **Global settings**: Redis URL and Zinit socket path
|
||||
- **Worker configurations**: Binary paths and environment variables for each worker type
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### 1. Build the CLI
|
||||
|
||||
```bash
|
||||
# From the supervisor directory
|
||||
cargo build --bin hive-supervisor --release
|
||||
```
|
||||
|
||||
### 2. Worker Management
|
||||
|
||||
```bash
|
||||
# Show help
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml --help
|
||||
|
||||
# List all configured workers
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml workers list
|
||||
|
||||
# Start all workers
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml workers start
|
||||
|
||||
# Start specific workers
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml workers start osis_worker sal_worker
|
||||
|
||||
# Check worker status
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml workers status
|
||||
|
||||
# Stop all workers
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml workers stop
|
||||
|
||||
# Restart specific worker
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml workers restart osis_worker
|
||||
```
|
||||
|
||||
### 3. Job Management
|
||||
|
||||
```bash
|
||||
# Create a job with inline script
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml jobs create \
|
||||
--script 'print("Hello from OSIS worker!");' \
|
||||
--script-type osis \
|
||||
--caller-id "user123" \
|
||||
--context-id "session456"
|
||||
|
||||
# Create a job from file
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml jobs create \
|
||||
--file examples/cli/sample_script.rhai \
|
||||
--script-type osis \
|
||||
--caller-id "user123" \
|
||||
--context-id "session456"
|
||||
|
||||
# List all jobs
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml jobs list
|
||||
|
||||
# Check job status
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml jobs status <JOB_ID>
|
||||
|
||||
# View job logs
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml jobs logs <JOB_ID>
|
||||
|
||||
# Stop a job
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml jobs stop <JOB_ID>
|
||||
```
|
||||
|
||||
### 4. Interactive REPL Mode
|
||||
|
||||
```bash
|
||||
# Enter REPL mode for OSIS scripts
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml repl \
|
||||
--caller-id "user123" \
|
||||
--context-id "session456" \
|
||||
--script-type osis \
|
||||
--timeout 60
|
||||
|
||||
# In REPL mode, you can:
|
||||
# - Type scripts directly and press Enter to execute
|
||||
# - Type 'help' for available commands
|
||||
# - Type 'exit' or 'quit' to leave REPL mode
|
||||
```
|
||||
|
||||
### 5. Verbose Logging
|
||||
|
||||
```bash
|
||||
# Enable debug logging
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml -v workers status
|
||||
|
||||
# Enable trace logging
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml -vv workers status
|
||||
|
||||
# Disable timestamps
|
||||
./target/release/hive-supervisor --config examples/cli/config.toml --no-timestamp workers status
|
||||
```
|
||||
|
||||
## Sample Scripts
|
||||
|
||||
The `sample_scripts/` directory contains example scripts for different worker types:
|
||||
|
||||
- `hello_osis.rhai` - Simple OSIS/HeroScript example
|
||||
- `system_sal.rhai` - SAL system operation example
|
||||
- `math_v.v` - V language calculation example
|
||||
- `data_python.py` - Python data processing example
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **Redis Connection Error**
|
||||
- Ensure Redis is running: `redis-cli ping`
|
||||
- Check the Redis URL in `config.toml`
|
||||
|
||||
2. **Zinit Socket Error**
|
||||
- Verify Zinit is running and the socket path is correct
|
||||
- Check permissions on the socket file
|
||||
|
||||
3. **Worker Binary Not Found**
|
||||
- Update binary paths in `config.toml` to match your system
|
||||
- Ensure worker binaries are executable
|
||||
|
||||
4. **Permission Denied**
|
||||
- Check file permissions on configuration and binary files
|
||||
- Ensure the user has access to the Zinit socket
|
||||
|
||||
### Debug Mode
|
||||
|
||||
Run with verbose logging to see detailed operation information:
|
||||
|
||||
```bash
|
||||
RUST_LOG=debug ./target/release/hive-supervisor --config examples/cli/config.toml -vv workers status
|
||||
```
|
||||
|
||||
## Configuration Customization
|
||||
|
||||
You can customize the configuration for your environment:
|
||||
|
||||
1. **Update Redis URL**: Change `redis_url` in the `[global]` section
|
||||
2. **Update Zinit Socket**: Change `zinit_socket_path` for your Zinit installation
|
||||
3. **Worker Paths**: Update binary paths in worker sections to match your setup
|
||||
4. **Environment Variables**: Add or modify environment variables for each worker type
|
||||
|
||||
## Integration with Hero Ecosystem
|
||||
|
||||
This CLI integrates with the broader Hero ecosystem:
|
||||
|
||||
- **Job Queue**: Uses Redis for job queuing and status tracking
|
||||
- **Process Management**: Uses Zinit for worker lifecycle management
|
||||
- **Script Execution**: Supports multiple script types (OSIS, SAL, V, Python)
|
||||
- **Monitoring**: Provides real-time status and logging capabilities
|
||||
|
||||
For more information about the Hero ecosystem, see the main project documentation.
|
19
core/supervisor/examples/cli/config.toml
Normal file
19
core/supervisor/examples/cli/config.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
# Hero Supervisor CLI Configuration Example
|
||||
# This configuration demonstrates how to set up the hive-supervisor CLI
|
||||
# with different worker types for script execution.
|
||||
|
||||
[global]
|
||||
# Redis connection URL for job queuing
|
||||
redis_url = "redis://localhost:6379"
|
||||
|
||||
# OSIS Worker Configuration
|
||||
# Handles OSIS (HeroScript) execution
|
||||
[osis_worker]
|
||||
binary_path = "/Users/timurgordon/code/git.ourworld.tf/herocode/hero/target/debug/osis"
|
||||
env_vars = { "RUST_LOG" = "info", "WORKER_TYPE" = "osis", "MAX_CONCURRENT_JOBS" = "5" }
|
||||
|
||||
# SAL Worker Configuration
|
||||
# Handles System Abstraction Layer scripts
|
||||
[sal_worker]
|
||||
binary_path = "/Users/timurgordon/code/git.ourworld.tf/herocode/hero/target/debug/sal"
|
||||
env_vars = { "RUST_LOG" = "info", "WORKER_TYPE" = "sal", "MAX_CONCURRENT_JOBS" = "3" }
|
144
core/supervisor/examples/cli/run_examples.sh
Executable file
144
core/supervisor/examples/cli/run_examples.sh
Executable file
@@ -0,0 +1,144 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Hero Supervisor CLI Example Runner
|
||||
# This script demonstrates various CLI operations
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SUPERVISOR_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
CONFIG_FILE="$SCRIPT_DIR/config.toml"
|
||||
CLI_BINARY="$SUPERVISOR_DIR/target/release/hive-supervisor"
|
||||
|
||||
echo -e "${BLUE}=== Hero Supervisor CLI Example Runner ===${NC}"
|
||||
echo "Script directory: $SCRIPT_DIR"
|
||||
echo "Supervisor directory: $SUPERVISOR_DIR"
|
||||
echo "Configuration file: $CONFIG_FILE"
|
||||
echo
|
||||
|
||||
# Function to run CLI command with error handling
|
||||
run_cli() {
|
||||
local description="$1"
|
||||
shift
|
||||
echo -e "${YELLOW}Running: $description${NC}"
|
||||
echo "Command: $CLI_BINARY --config $CONFIG_FILE $*"
|
||||
echo
|
||||
|
||||
if "$CLI_BINARY" --config "$CONFIG_FILE" "$@"; then
|
||||
echo -e "${GREEN}✓ Success${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ Failed${NC}"
|
||||
return 1
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
# Check if CLI binary exists
|
||||
if [[ ! -f "$CLI_BINARY" ]]; then
|
||||
echo -e "${YELLOW}Building CLI binary...${NC}"
|
||||
cd "$SUPERVISOR_DIR"
|
||||
cargo build --bin hive-supervisor --release
|
||||
echo
|
||||
fi
|
||||
|
||||
# Check if config file exists
|
||||
if [[ ! -f "$CONFIG_FILE" ]]; then
|
||||
echo -e "${RED}Error: Configuration file not found: $CONFIG_FILE${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}=== CLI Help and Information ===${NC}"
|
||||
run_cli "Show main help" --help
|
||||
|
||||
echo -e "${BLUE}=== Worker Management Examples ===${NC}"
|
||||
run_cli "List configured workers" workers list
|
||||
run_cli "Show worker management help" workers --help
|
||||
|
||||
# Note: These commands would require actual worker binaries and Zinit setup
|
||||
echo -e "${YELLOW}Note: The following commands require actual worker binaries and Zinit setup${NC}"
|
||||
echo -e "${YELLOW}They are shown for demonstration but may fail without proper setup${NC}"
|
||||
echo
|
||||
|
||||
# Uncomment these if you have the proper setup
|
||||
# run_cli "Check worker status" workers status
|
||||
# run_cli "Start all workers" workers start
|
||||
# run_cli "Check worker status after start" workers status
|
||||
|
||||
echo -e "${BLUE}=== Job Management Examples ===${NC}"
|
||||
run_cli "Show job management help" jobs --help
|
||||
|
||||
# Create sample jobs (these will also require workers to be running)
|
||||
echo -e "${YELLOW}Sample job creation commands (require running workers):${NC}"
|
||||
echo
|
||||
|
||||
echo "# Create OSIS job with inline script:"
|
||||
echo "$CLI_BINARY --config $CONFIG_FILE jobs create \\"
|
||||
echo " --script 'print(\"Hello from CLI!\");' \\"
|
||||
echo " --script-type osis \\"
|
||||
echo " --caller-id \"cli_demo\" \\"
|
||||
echo " --context-id \"example_session\""
|
||||
echo
|
||||
|
||||
echo "# Create job from sample script file:"
|
||||
echo "$CLI_BINARY --config $CONFIG_FILE jobs create \\"
|
||||
echo " --file \"$SCRIPT_DIR/sample_scripts/hello_osis.rhai\" \\"
|
||||
echo " --script-type osis \\"
|
||||
echo " --caller-id \"cli_demo\" \\"
|
||||
echo " --context-id \"example_session\""
|
||||
echo
|
||||
|
||||
echo "# List all jobs:"
|
||||
echo "$CLI_BINARY --config $CONFIG_FILE jobs list"
|
||||
echo
|
||||
|
||||
echo "# Check job status (replace JOB_ID with actual job ID):"
|
||||
echo "$CLI_BINARY --config $CONFIG_FILE jobs status JOB_ID"
|
||||
echo
|
||||
|
||||
echo -e "${BLUE}=== REPL Mode Example ===${NC}"
|
||||
echo -e "${YELLOW}REPL mode command (interactive):${NC}"
|
||||
echo "$CLI_BINARY --config $CONFIG_FILE repl \\"
|
||||
echo " --caller-id \"cli_demo\" \\"
|
||||
echo " --context-id \"example_session\" \\"
|
||||
echo " --script-type osis \\"
|
||||
echo " --timeout 60"
|
||||
echo
|
||||
|
||||
echo -e "${BLUE}=== Sample Scripts ===${NC}"
|
||||
echo "Available sample scripts in $SCRIPT_DIR/sample_scripts/:"
|
||||
for script in "$SCRIPT_DIR/sample_scripts"/*; do
|
||||
if [[ -f "$script" ]]; then
|
||||
basename "$script"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
|
||||
echo -e "${BLUE}=== Verbose Logging Examples ===${NC}"
|
||||
echo "# Debug logging:"
|
||||
echo "$CLI_BINARY --config $CONFIG_FILE -v workers list"
|
||||
echo
|
||||
echo "# Trace logging:"
|
||||
echo "$CLI_BINARY --config $CONFIG_FILE -vv workers list"
|
||||
echo
|
||||
echo "# No timestamps:"
|
||||
echo "$CLI_BINARY --config $CONFIG_FILE --no-timestamp workers list"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}=== Example Runner Complete ===${NC}"
|
||||
echo -e "${YELLOW}To run actual commands, ensure you have:${NC}"
|
||||
echo "1. Redis server running on localhost:6379"
|
||||
echo "2. Zinit process manager installed and configured"
|
||||
echo "3. Worker binaries available at the paths specified in config.toml"
|
||||
echo
|
||||
echo -e "${YELLOW}For testing without full setup, you can:${NC}"
|
||||
echo "1. Update config.toml with paths to existing binaries"
|
||||
echo "2. Use the CLI help commands and configuration validation"
|
||||
echo "3. Test the REPL mode (requires workers to be running)"
|
90
core/supervisor/examples/cli/sample_scripts/data_python.py
Normal file
90
core/supervisor/examples/cli/sample_scripts/data_python.py
Normal file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Sample Python script for demonstration
|
||||
This script demonstrates Python worker functionality
|
||||
"""
|
||||
|
||||
import json
|
||||
import datetime
|
||||
from typing import List, Dict
|
||||
|
||||
def main():
|
||||
print("=== Python Worker Demo ===")
|
||||
print("Python data processing operations")
|
||||
|
||||
# Data structures
|
||||
print("\nData structures:")
|
||||
users = [
|
||||
{"id": 1, "name": "Alice", "age": 30, "role": "developer"},
|
||||
{"id": 2, "name": "Bob", "age": 25, "role": "designer"},
|
||||
{"id": 3, "name": "Charlie", "age": 35, "role": "manager"},
|
||||
{"id": 4, "name": "Diana", "age": 28, "role": "developer"}
|
||||
]
|
||||
|
||||
print(f"Total users: {len(users)}")
|
||||
|
||||
# Data filtering
|
||||
developers = [user for user in users if user["role"] == "developer"]
|
||||
print(f"Developers: {len(developers)}")
|
||||
for dev in developers:
|
||||
print(f" - {dev['name']} (age {dev['age']})")
|
||||
|
||||
# Statistical operations
|
||||
print("\nStatistical operations:")
|
||||
ages = [user["age"] for user in users]
|
||||
avg_age = sum(ages) / len(ages)
|
||||
min_age = min(ages)
|
||||
max_age = max(ages)
|
||||
|
||||
print(f"Average age: {avg_age:.1f}")
|
||||
print(f"Age range: {min_age} - {max_age}")
|
||||
|
||||
# Date/time operations
|
||||
print("\nDate/time operations:")
|
||||
now = datetime.datetime.now()
|
||||
print(f"Current time: {now.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
|
||||
# Calculate birth years
|
||||
current_year = now.year
|
||||
for user in users:
|
||||
birth_year = current_year - user["age"]
|
||||
print(f"{user['name']} was born in {birth_year}")
|
||||
|
||||
# JSON processing
|
||||
print("\nJSON processing:")
|
||||
json_data = json.dumps(users, indent=2)
|
||||
print("User data as JSON:")
|
||||
print(json_data[:200] + "..." if len(json_data) > 200 else json_data)
|
||||
|
||||
# File operations simulation
|
||||
print("\nFile operations:")
|
||||
simulate_file_processing()
|
||||
|
||||
print("=== Python Demo Complete ===")
|
||||
|
||||
def simulate_file_processing():
|
||||
"""Simulate file processing operations"""
|
||||
files = [
|
||||
{"name": "data.csv", "size": 1024, "type": "csv"},
|
||||
{"name": "config.json", "size": 512, "type": "json"},
|
||||
{"name": "report.pdf", "size": 2048, "type": "pdf"},
|
||||
{"name": "script.py", "size": 768, "type": "python"}
|
||||
]
|
||||
|
||||
total_size = sum(file["size"] for file in files)
|
||||
print(f"Processing {len(files)} files, total size: {total_size} bytes")
|
||||
|
||||
# Group by type
|
||||
file_types = {}
|
||||
for file in files:
|
||||
file_type = file["type"]
|
||||
if file_type not in file_types:
|
||||
file_types[file_type] = []
|
||||
file_types[file_type].append(file["name"])
|
||||
|
||||
print("Files by type:")
|
||||
for file_type, file_names in file_types.items():
|
||||
print(f" {file_type}: {', '.join(file_names)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
34
core/supervisor/examples/cli/sample_scripts/hello_osis.rhai
Normal file
34
core/supervisor/examples/cli/sample_scripts/hello_osis.rhai
Normal file
@@ -0,0 +1,34 @@
|
||||
// Sample OSIS/HeroScript for demonstration
|
||||
// This script demonstrates basic OSIS worker functionality
|
||||
|
||||
print("=== OSIS Worker Demo ===");
|
||||
print("Hello from the OSIS worker!");
|
||||
|
||||
// Basic variable operations
|
||||
let name = "Hero";
|
||||
let version = "1.0";
|
||||
print(`Running ${name} version ${version}`);
|
||||
|
||||
// Simple calculation
|
||||
let x = 10;
|
||||
let y = 20;
|
||||
let result = x + y;
|
||||
print(`Calculation: ${x} + ${y} = ${result}`);
|
||||
|
||||
// Array operations
|
||||
let numbers = [1, 2, 3, 4, 5];
|
||||
let sum = 0;
|
||||
for num in numbers {
|
||||
sum += num;
|
||||
}
|
||||
print(`Sum of array [1,2,3,4,5]: ${sum}`);
|
||||
|
||||
// Function definition and call
|
||||
fn greet(person) {
|
||||
return `Hello, ${person}! Welcome to Hero.`;
|
||||
}
|
||||
|
||||
let greeting = greet("Developer");
|
||||
print(greeting);
|
||||
|
||||
print("=== OSIS Demo Complete ===");
|
67
core/supervisor/examples/cli/sample_scripts/math_v.v
Normal file
67
core/supervisor/examples/cli/sample_scripts/math_v.v
Normal file
@@ -0,0 +1,67 @@
|
||||
// Sample V language script for demonstration
|
||||
// This script demonstrates V worker functionality
|
||||
|
||||
module main
|
||||
|
||||
import math
|
||||
|
||||
fn main() {
|
||||
println("=== V Worker Demo ===")
|
||||
println("V language mathematical operations")
|
||||
|
||||
// Basic arithmetic
|
||||
x := 15
|
||||
y := 25
|
||||
sum := x + y
|
||||
product := x * y
|
||||
println("Basic arithmetic:")
|
||||
println("${x} + ${y} = ${sum}")
|
||||
println("${x} * ${y} = ${product}")
|
||||
|
||||
// Mathematical functions
|
||||
println("\nMathematical functions:")
|
||||
angle := 45.0
|
||||
sin_val := math.sin(math.radians(angle))
|
||||
cos_val := math.cos(math.radians(angle))
|
||||
println("sin(${angle}°) = ${sin_val:.4f}")
|
||||
println("cos(${angle}°) = ${cos_val:.4f}")
|
||||
|
||||
// Array operations
|
||||
numbers := [1, 4, 9, 16, 25]
|
||||
println("\nArray operations:")
|
||||
println("Numbers: ${numbers}")
|
||||
|
||||
mut total := 0
|
||||
for num in numbers {
|
||||
total += num
|
||||
}
|
||||
println("Sum: ${total}")
|
||||
|
||||
// Square roots
|
||||
println("\nSquare roots:")
|
||||
for num in numbers {
|
||||
sqrt_val := math.sqrt(f64(num))
|
||||
println("√${num} = ${sqrt_val:.2f}")
|
||||
}
|
||||
|
||||
// Fibonacci sequence
|
||||
println("\nFibonacci sequence (first 10 numbers):")
|
||||
fib := fibonacci(10)
|
||||
println("${fib}")
|
||||
|
||||
println("=== V Demo Complete ===")
|
||||
}
|
||||
|
||||
fn fibonacci(n int) []int {
|
||||
mut fib := []int{len: n}
|
||||
if n >= 1 {
|
||||
fib[0] = 0
|
||||
}
|
||||
if n >= 2 {
|
||||
fib[1] = 1
|
||||
}
|
||||
for i in 2 .. n {
|
||||
fib[i] = fib[i-1] + fib[i-2]
|
||||
}
|
||||
return fib
|
||||
}
|
43
core/supervisor/examples/cli/sample_scripts/system_sal.rhai
Normal file
43
core/supervisor/examples/cli/sample_scripts/system_sal.rhai
Normal file
@@ -0,0 +1,43 @@
|
||||
// Sample SAL (System Abstraction Layer) script for demonstration
|
||||
// This script demonstrates system-level operations through SAL worker
|
||||
|
||||
print("=== SAL Worker Demo ===");
|
||||
print("System Abstraction Layer operations");
|
||||
|
||||
// System information gathering
|
||||
print("Gathering system information...");
|
||||
|
||||
// Simulated system operations (actual SAL would have real system calls)
|
||||
let hostname = "hero-system";
|
||||
let uptime = "2 days, 4 hours";
|
||||
let load_avg = "0.45, 0.52, 0.48";
|
||||
|
||||
print(`Hostname: ${hostname}`);
|
||||
print(`Uptime: ${uptime}`);
|
||||
print(`Load Average: ${load_avg}`);
|
||||
|
||||
// File system operations
|
||||
print("\nFile system operations:");
|
||||
let disk_usage = "45% used";
|
||||
let available_space = "120GB available";
|
||||
|
||||
print(`Disk Usage: ${disk_usage}`);
|
||||
print(`Available Space: ${available_space}`);
|
||||
|
||||
// Process management simulation
|
||||
print("\nProcess management:");
|
||||
let active_processes = 156;
|
||||
let memory_usage = "68%";
|
||||
|
||||
print(`Active Processes: ${active_processes}`);
|
||||
print(`Memory Usage: ${memory_usage}`);
|
||||
|
||||
// Network status
|
||||
print("\nNetwork status:");
|
||||
let network_interfaces = ["eth0", "lo"];
|
||||
let connectivity = "Connected";
|
||||
|
||||
print(`Network Interfaces: ${network_interfaces}`);
|
||||
print(`Connectivity: ${connectivity}`);
|
||||
|
||||
print("=== SAL Demo Complete ===");
|
@@ -17,7 +17,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Configuration
|
||||
let redis_url = "redis://localhost:6379";
|
||||
let zinit_socket = "/var/run/zinit.sock";
|
||||
|
||||
// Create supervisor
|
||||
let supervisor = SupervisorBuilder::new()
|
||||
|
@@ -12,7 +12,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Workers are automatically launched during build
|
||||
let supervisor = SupervisorBuilder::new()
|
||||
.redis_url("redis://localhost:6379")
|
||||
.zinit_socket_path("/var/run/zinit.sock")
|
||||
.osis_worker("/usr/local/bin/osis_worker")
|
||||
.sal_worker("/usr/local/bin/sal_worker")
|
||||
.v_worker("/usr/local/bin/v_worker")
|
||||
|
18
core/supervisor/examples/supervisor_config.toml
Normal file
18
core/supervisor/examples/supervisor_config.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
[global]
|
||||
redis_url = "redis://localhost:6379"
|
||||
|
||||
[osis_worker]
|
||||
binary_path = "/path/to/osis_worker"
|
||||
env_vars = { "VAR1" = "value1", "VAR2" = "value2" }
|
||||
|
||||
[sal_worker]
|
||||
binary_path = "/path/to/sal_worker"
|
||||
env_vars = { "VAR1" = "value1", "VAR2" = "value2" }
|
||||
|
||||
[v_worker]
|
||||
binary_path = "/path/to/v_worker"
|
||||
env_vars = { "VAR1" = "value1", "VAR2" = "value2" }
|
||||
|
||||
[python_worker]
|
||||
binary_path = "/path/to/python_worker"
|
||||
env_vars = { "VAR1" = "value1", "VAR2" = "value2" }
|
Reference in New Issue
Block a user