| 279 | } |
| 280 | |
| 281 | pub fn refresh_installed_service(spec: &DaemonServiceSpec) -> Result<Option<PathBuf>> { |
| 282 | let service_path = service_unit_path()?; |
| 283 | if !service_path.exists() { |
| 284 | return Ok(None); |
| 285 | } |
| 286 | let unit = read_service_unit(&service_path)?; |
| 287 | let mut refreshed_spec = spec.clone(); |
| 288 | if let Some(socket_path) = socket_path_from_unit_text(&unit) { |
| 289 | refreshed_spec.socket_path = socket_path; |
| 290 | } |
| 291 | if matches!(ServiceRunner::current(), Ok(ServiceRunner::Launchd)) { |
| 292 | // The installed plist is the source of truth for the daemon's data |
| 293 | // directory; the refreshing shell may not have the override set. |
| 294 | refreshed_spec.data_dir_override = |
| 295 | launchd_plist_env_value(&unit, crate::config::USER_DATA_DIR_ENV).map(PathBuf::from); |
| 296 | } |
| 297 | refresh_service(&refreshed_spec).map(Some) |
| 298 | } |
| 299 | |
| 300 | fn write_service_unit(spec: &DaemonServiceSpec) -> Result<PathBuf> { |
| 301 | let service_path = service_unit_path()?; |