fix: rename overview.md files to avoid conflicts and add collection name
This commit is contained in:
@@ -13,8 +13,6 @@ pub struct Runner {
|
||||
pub address: IpAddr,
|
||||
/// Needs to be set by the runner, usually `runner<runnerid`
|
||||
pub topic: String,
|
||||
/// The executor this runner can handle (e.g., "python", "rhai"); used for routing
|
||||
pub executor: String,
|
||||
/// If this is true, the runner also listens on a local redis queue
|
||||
pub local: bool,
|
||||
/// Optional secret used for authenticated supervisor calls (if required)
|
||||
|
||||
@@ -135,8 +135,6 @@ pub struct RunnerCreate {
|
||||
pub pubkey: String,
|
||||
pub address: IpAddr,
|
||||
pub topic: String,
|
||||
/// The executor this runner can handle (e.g., "python", "rhai")
|
||||
pub executor: String,
|
||||
pub local: bool,
|
||||
/// Optional secret used for authenticated supervisor calls (if required)
|
||||
pub secret: Option<String>,
|
||||
@@ -150,7 +148,6 @@ impl RunnerCreate {
|
||||
pubkey,
|
||||
address,
|
||||
topic,
|
||||
executor,
|
||||
local,
|
||||
secret,
|
||||
} = self;
|
||||
@@ -160,7 +157,6 @@ impl RunnerCreate {
|
||||
pubkey,
|
||||
address,
|
||||
topic,
|
||||
executor,
|
||||
local,
|
||||
secret,
|
||||
created_at: ts,
|
||||
@@ -211,7 +207,6 @@ pub struct JobCreate {
|
||||
pub context_id: u32,
|
||||
pub script: String,
|
||||
pub runner: Option<String>,
|
||||
pub executor: Option<String>,
|
||||
pub timeout: u32,
|
||||
pub retries: u8,
|
||||
pub env_vars: HashMap<String, String>,
|
||||
@@ -231,7 +226,6 @@ impl JobCreate {
|
||||
context_id: self.context_id.to_string(),
|
||||
payload: self.script,
|
||||
runner: self.runner.unwrap_or_else(|| "default-runner".to_string()),
|
||||
executor: self.executor.unwrap_or_else(|| "python".to_string()),
|
||||
timeout: self.timeout as u64,
|
||||
env_vars: self.env_vars,
|
||||
created_at: Utc::now(),
|
||||
|
||||
@@ -425,7 +425,7 @@ impl AppService {
|
||||
context_id,
|
||||
flow_id,
|
||||
message: "job.run".to_string(),
|
||||
message_type: job.executor.clone(),
|
||||
message_type: job.runner.clone(),
|
||||
message_format_type: MessageFormatType::Text,
|
||||
timeout: job.timeout as u32,
|
||||
timeout_ack: 10,
|
||||
@@ -503,7 +503,7 @@ impl AppService {
|
||||
context_id,
|
||||
flow_id, // Add flow_id for DAG tracking
|
||||
message: "job.run".to_string(),
|
||||
message_type: job.executor.clone(),
|
||||
message_type: job.runner.clone(),
|
||||
message_format_type: MessageFormatType::Text,
|
||||
timeout: job.timeout as u32,
|
||||
timeout_ack: 10,
|
||||
|
||||
@@ -4,16 +4,16 @@ A specialized runner for the Hero ecosystem that executes heroscripts using the
|
||||
|
||||
## Overview
|
||||
|
||||
The Hero runner executes heroscripts by calling `hero run -h <payload>` for each job. This makes it ideal for:
|
||||
The Hero runner executes heroscripts by piping the payload to `hero run -s` via stdin for each job. This makes it ideal for:
|
||||
|
||||
- Running heroscripts from job payloads
|
||||
- Executing Hero automation tasks
|
||||
- Executing Hero automation tasks (e.g., `!!git.list`, `!!docker.start`)
|
||||
- Integrating with the Hero CLI ecosystem
|
||||
- Running scripted workflows
|
||||
|
||||
## Features
|
||||
|
||||
- **Heroscript Execution**: Executes `hero run -h <payload>` for each job
|
||||
- **Heroscript Execution**: Pipes payload to `hero run -s` via stdin (no temp files)
|
||||
- **Environment Variables**: Passes job environment variables to the hero command
|
||||
- **Timeout Support**: Respects job timeout settings
|
||||
- **Signature Verification**: Verifies job signatures before execution
|
||||
@@ -38,15 +38,28 @@ herorunner my-hero-runner --redis-url redis://localhost:6379
|
||||
|
||||
## Job Payload Format
|
||||
|
||||
The job payload should contain the heroscript content that will be passed to `hero run -h`.
|
||||
The job payload should contain the heroscript content. The runner will pipe it directly to `hero run -s` via stdin.
|
||||
|
||||
### Example Payload
|
||||
### Example Payloads
|
||||
|
||||
**Simple print:**
|
||||
```
|
||||
print("Hello from heroscript!")
|
||||
```
|
||||
|
||||
The runner will execute: `hero run -h 'print("Hello from heroscript!")'`
|
||||
**Hero actions:**
|
||||
```
|
||||
!!git.list
|
||||
```
|
||||
|
||||
**Multi-line script:**
|
||||
```
|
||||
!!git.list
|
||||
print("Repositories listed")
|
||||
!!docker.ps
|
||||
```
|
||||
|
||||
The runner executes: `echo "<payload>" | hero run -s`
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
@@ -25,21 +25,22 @@ impl HeroExecutor {
|
||||
|
||||
/// Execute a command from the job payload
|
||||
fn execute_command(&self, job: &Job) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
|
||||
info!("Runner '{}': Executing hero run -h for job {}", self.runner_id, job.id);
|
||||
info!("Runner '{}': Executing hero run for job {}", self.runner_id, job.id);
|
||||
|
||||
// Always execute: hero run -h <payload>
|
||||
// Execute: hero run -s (reads from stdin)
|
||||
let mut cmd = Command::new("hero");
|
||||
cmd.args(&["run", "-h", &job.payload]);
|
||||
cmd.args(&["run", "-s"]);
|
||||
|
||||
debug!("Runner '{}': Executing: hero run -h {}", self.runner_id, job.payload);
|
||||
debug!("Runner '{}': Executing: hero run -s with stdin", self.runner_id);
|
||||
|
||||
// Set environment variables from job
|
||||
for (key, value) in &job.env_vars {
|
||||
cmd.env(key, value);
|
||||
}
|
||||
|
||||
// Configure stdio
|
||||
cmd.stdout(Stdio::piped())
|
||||
// Configure stdio - pipe stdin to send heroscript content
|
||||
cmd.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped());
|
||||
|
||||
// Execute command with timeout
|
||||
@@ -49,7 +50,16 @@ impl HeroExecutor {
|
||||
info!("Runner '{}': Starting command execution for job {}", self.runner_id, job.id);
|
||||
|
||||
let mut child = cmd.spawn()
|
||||
.map_err(|e| format!("Failed to spawn 'hero run -h': {}", e))?;
|
||||
.map_err(|e| format!("Failed to spawn 'hero run -s': {}", e))?;
|
||||
|
||||
// Write heroscript payload to stdin
|
||||
if let Some(mut stdin) = child.stdin.take() {
|
||||
use std::io::Write;
|
||||
stdin.write_all(job.payload.as_bytes())
|
||||
.map_err(|e| format!("Failed to write to stdin: {}", e))?;
|
||||
// Close stdin to signal EOF
|
||||
drop(stdin);
|
||||
}
|
||||
|
||||
// Wait for command with timeout
|
||||
let output = loop {
|
||||
|
||||
@@ -152,11 +152,10 @@ mod tests {
|
||||
}
|
||||
|
||||
fn create_test_job(id: &str, runner: &str) -> Job {
|
||||
let mut job = JobBuilder::new()
|
||||
let job = JobBuilder::new()
|
||||
.caller_id("test_caller")
|
||||
.context_id("test_context")
|
||||
.runner(runner)
|
||||
.executor("test")
|
||||
.payload("test payload")
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
@@ -81,7 +81,6 @@ impl Supervisor {
|
||||
.context_id("ping_context")
|
||||
.payload("ping")
|
||||
.runner(runner_id)
|
||||
.executor("ping")
|
||||
.timeout(10)
|
||||
.build()
|
||||
.map_err(|e| SupervisorError::QueueError {
|
||||
|
||||
Reference in New Issue
Block a user