(
project_root: Option<&Path>,
)
| 1682 | } |
| 1683 | |
| 1684 | fn cleanup_orphaned_workspace_services( |
| 1685 | project_root: Option<&Path>, |
| 1686 | ) -> anyhow::Result<Vec<WorkspaceServiceProcess>> { |
| 1687 | let metadata_by_path = service_metadata_by_path()?; |
| 1688 | let mut killed = Vec::new(); |
| 1689 | let mut killed_groups = HashSet::new(); |
| 1690 | |
| 1691 | for process in workspace_service_processes()? { |
| 1692 | if project_root.is_some_and(|root| process.project_root != root) { |
| 1693 | continue; |
| 1694 | } |
| 1695 | if workspace_service_process_is_current(&process, &metadata_by_path) { |
| 1696 | continue; |
| 1697 | } |
| 1698 | if killed_groups.insert(process.pgid) { |
| 1699 | terminate_process_group_with_kill_timeout( |
| 1700 | process.pgid, |
| 1701 | ORPHAN_WORKSPACE_SERVICE_SHUTDOWN_GRACE, |
| 1702 | ORPHAN_WORKSPACE_SERVICE_KILL_GRACE, |
| 1703 | ); |
| 1704 | killed.push(process); |
| 1705 | } |
| 1706 | } |
| 1707 | |
| 1708 | Ok(killed) |
| 1709 | } |
| 1710 | |
| 1711 | fn workspace_service_process_is_current( |
| 1712 | process: &WorkspaceServiceProcess, |
no test coverage detected