remove unused dep and move job out
This commit is contained in:
@@ -1,13 +1,56 @@
|
||||
//! Runner implementation for actor process management.
|
||||
|
||||
use sal_service_manager::{ProcessManagerError as ServiceProcessManagerError, ProcessStatus, ProcessConfig};
|
||||
// use sal_service_manager::{ProcessManagerError as ServiceProcessManagerError, ProcessStatus, ProcessConfig};
|
||||
|
||||
/// Simple process status enum to replace sal_service_manager dependency
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ProcessStatus {
|
||||
NotStarted,
|
||||
Starting,
|
||||
Running,
|
||||
Stopping,
|
||||
Stopped,
|
||||
Failed,
|
||||
Error(String),
|
||||
}
|
||||
|
||||
/// Simple process config to replace sal_service_manager dependency
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ProcessConfig {
|
||||
pub command: String,
|
||||
pub args: Vec<String>,
|
||||
pub working_dir: Option<String>,
|
||||
pub env_vars: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
impl ProcessConfig {
|
||||
pub fn new(command: String, args: Vec<String>, working_dir: Option<String>, env_vars: Vec<(String, String)>) -> Self {
|
||||
Self {
|
||||
command,
|
||||
args,
|
||||
working_dir,
|
||||
env_vars,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Simple process manager error to replace sal_service_manager dependency
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ProcessManagerError {
|
||||
#[error("Process execution failed: {0}")]
|
||||
ExecutionFailed(String),
|
||||
#[error("Process not found: {0}")]
|
||||
ProcessNotFound(String),
|
||||
#[error("IO error: {0}")]
|
||||
IoError(String),
|
||||
}
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Represents the current status of an actor/runner (alias for ProcessStatus)
|
||||
pub type RunnerStatus = ProcessStatus;
|
||||
|
||||
/// Log information structure
|
||||
#[derive(Debug, Clone)]
|
||||
/// Log information structure with serialization support
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct LogInfo {
|
||||
pub timestamp: String,
|
||||
pub level: String,
|
||||
@@ -96,7 +139,7 @@ pub enum RunnerError {
|
||||
#[error("Process manager error: {source}")]
|
||||
ProcessManagerError {
|
||||
#[from]
|
||||
source: ServiceProcessManagerError,
|
||||
source: ProcessManagerError,
|
||||
},
|
||||
|
||||
#[error("Configuration error: {reason}")]
|
||||
@@ -120,7 +163,7 @@ pub enum RunnerError {
|
||||
#[error("Job error: {source}")]
|
||||
JobError {
|
||||
#[from]
|
||||
source: crate::JobError,
|
||||
source: hero_job::JobError,
|
||||
},
|
||||
|
||||
#[error("Job '{job_id}' not found")]
|
||||
@@ -135,9 +178,17 @@ pub type RunnerConfig = Runner;
|
||||
|
||||
/// Convert Runner to ProcessConfig
|
||||
pub fn runner_to_process_config(config: &Runner) -> ProcessConfig {
|
||||
ProcessConfig::new(config.id.clone(), config.command.clone())
|
||||
.with_arg("--id".to_string())
|
||||
.with_arg(config.id.clone())
|
||||
.with_arg("--redis-url".to_string())
|
||||
.with_arg(config.redis_url.clone())
|
||||
let args = vec![
|
||||
"--id".to_string(),
|
||||
config.id.clone(),
|
||||
"--redis-url".to_string(),
|
||||
config.redis_url.clone(),
|
||||
];
|
||||
|
||||
ProcessConfig::new(
|
||||
config.command.to_string_lossy().to_string(),
|
||||
args,
|
||||
Some("/tmp".to_string()), // Default working directory since Runner doesn't have working_dir field
|
||||
vec![]
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user