Update osiris dependency to use osiris-core package
This commit is contained in:
@@ -3,6 +3,7 @@ use crate::runner_trait::Runner;
|
||||
use log::{debug, error, info};
|
||||
use rhai::{Engine, Dynamic};
|
||||
use std::sync::Arc;
|
||||
use tracing::subscriber::with_default;
|
||||
|
||||
/// Configuration for sync runner instances
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -72,11 +73,58 @@ impl Runner for SyncRunner {
|
||||
debug!("Sync Runner '{}', Job {}: Processing started.", runner_id, job_id);
|
||||
info!("Sync Runner '{}' processing job_id: {}. Script: {:.50}...", job.context_id, job_id, job.payload);
|
||||
|
||||
// Create a new engine instance (cheap with factory pattern)
|
||||
let mut engine = (self.engine_factory)();
|
||||
// Determine logs directory (default to ~/hero/logs)
|
||||
let logs_root = if let Some(home) = std::env::var_os("HOME") {
|
||||
std::path::PathBuf::from(home).join("hero").join("logs")
|
||||
} else {
|
||||
std::path::PathBuf::from("logs")
|
||||
};
|
||||
|
||||
// Execute the script
|
||||
match Self::execute_job_with_engine(&mut engine, &job) {
|
||||
// Create job-specific logger
|
||||
let job_logger_result = hero_logger::create_job_logger_with_guard(
|
||||
&logs_root,
|
||||
runner_id, // Use runner_id as the actor_type
|
||||
job_id,
|
||||
);
|
||||
|
||||
// Verify signatures before executing (if any)
|
||||
if let Err(e) = job.verify_signatures() {
|
||||
error!("Job {} signature verification failed: {}", job_id, e);
|
||||
return Err(Box::new(e));
|
||||
}
|
||||
|
||||
// Execute job within logging context
|
||||
let result = match job_logger_result {
|
||||
Ok((job_logger, _guard)) => {
|
||||
// Execute ALL job processing within logging context
|
||||
with_default(job_logger, || {
|
||||
tracing::info!("Job {} started", job_id);
|
||||
|
||||
// Create a new engine instance and configure Rhai logging
|
||||
let mut engine = (self.engine_factory)();
|
||||
|
||||
// Reconfigure Rhai logging for this specific job context
|
||||
// This ensures print() and debug() calls go to the job logger
|
||||
hero_logger::rhai_integration::configure_rhai_logging(&mut engine, runner_id);
|
||||
|
||||
// Execute the script
|
||||
let script_result = Self::execute_job_with_engine(&mut engine, &job);
|
||||
|
||||
tracing::info!("Job {} completed", job_id);
|
||||
|
||||
script_result
|
||||
})
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to create job logger for job {}: {}", job_id, e);
|
||||
// Fallback: execute without job-specific logging
|
||||
let mut engine = (self.engine_factory)();
|
||||
Self::execute_job_with_engine(&mut engine, &job)
|
||||
}
|
||||
};
|
||||
|
||||
// Process result
|
||||
match result {
|
||||
Ok(result) => {
|
||||
let output_str = if result.is::<String>() {
|
||||
result.into_string().unwrap()
|
||||
|
||||
Reference in New Issue
Block a user