| 582 | } |
| 583 | |
| 584 | async fn sv_list(self) -> Result<SvListResponse> { |
| 585 | use supervisor_client::supervisor::ProcessStatus; |
| 586 | let list = self.app.supervisor.list().await?; |
| 587 | let processes = list |
| 588 | .into_iter() |
| 589 | .map(|p| { |
| 590 | let status = match &p.state.status { |
| 591 | ProcessStatus::Running => "running".into(), |
| 592 | ProcessStatus::Stopped => "stopped".into(), |
| 593 | ProcessStatus::Exited(code) => format!("exited({code})"), |
| 594 | ProcessStatus::Error(msg) => format!("error({msg})"), |
| 595 | }; |
| 596 | SvProcessInfo { |
| 597 | id: p.config.id, |
| 598 | name: p.config.name, |
| 599 | status, |
| 600 | pid: p.state.pid, |
| 601 | command: p.config.command, |
| 602 | note: p.config.note, |
| 603 | } |
| 604 | }) |
| 605 | .collect(); |
| 606 | Ok(SvListResponse { processes }) |
| 607 | } |
| 608 | |
| 609 | async fn sv_stop(self, request: Id) -> Result<()> { |
| 610 | self.app.supervisor.stop(&request.id).await?; |