| 52 | } |
| 53 | |
| 54 | pub fn deploy(&self, config: ProcessConfig) -> Result<()> { |
| 55 | if self.freezed() { |
| 56 | bail!("Supervisor is freezed"); |
| 57 | } |
| 58 | let id = config.id.clone(); |
| 59 | if id.is_empty() { |
| 60 | return Err(anyhow::anyhow!("Process ID is empty")); |
| 61 | } |
| 62 | if self |
| 63 | .info(&id) |
| 64 | .is_some_and(|info| info.state.status.is_running()) |
| 65 | { |
| 66 | bail!("Process is already running"); |
| 67 | } |
| 68 | let process = Process::new(config); |
| 69 | process.start()?; |
| 70 | info!("Deployed process {id}"); |
| 71 | self.processes.insert(id, process); |
| 72 | Ok(()) |
| 73 | } |
| 74 | |
| 75 | pub fn start(&self, id: &str) -> Result<()> { |
| 76 | let process = self.processes.get(id).context("Process not found")?; |