feat: Improve zinit service manager fallback
- Try multiple socket paths for zinit before falling back to systemd. - This improves the robustness of the service manager selection, handling cases where the zinit socket path might vary.
This commit is contained in:
parent
352e846410
commit
8cb9696421
@ -122,23 +122,27 @@ pub fn create_service_manager() -> Result<Box<dyn ServiceManager>, ServiceManage
|
|||||||
}
|
}
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
// Try zinit first (preferred), fall back to systemd if it fails
|
// Try zinit first (preferred), with multiple socket paths, fall back to systemd if all fail
|
||||||
let socket_path = "/tmp/zinit.sock";
|
let socket_paths = ["/run/zinit.sock", "/tmp/zinit.sock", "/var/run/zinit.sock"];
|
||||||
|
|
||||||
|
for socket_path in &socket_paths {
|
||||||
|
log::debug!("Trying zinit socket: {}", socket_path);
|
||||||
match ZinitServiceManager::new(socket_path) {
|
match ZinitServiceManager::new(socket_path) {
|
||||||
Ok(zinit_manager) => {
|
Ok(zinit_manager) => {
|
||||||
log::debug!("Using zinit service manager");
|
log::debug!("Using zinit service manager with socket: {}", socket_path);
|
||||||
Ok(Box::new(zinit_manager))
|
return Ok(Box::new(zinit_manager));
|
||||||
}
|
}
|
||||||
Err(zinit_error) => {
|
Err(zinit_error) => {
|
||||||
log::warn!(
|
log::debug!("Zinit socket {} failed: {}", socket_path, zinit_error);
|
||||||
"Zinit service manager failed, falling back to systemd: {}",
|
continue;
|
||||||
zinit_error
|
}
|
||||||
);
|
}
|
||||||
// Fallback to systemd
|
}
|
||||||
|
|
||||||
|
log::warn!("All zinit sockets failed, falling back to systemd");
|
||||||
|
// Fallback to systemd if all zinit attempts fail
|
||||||
Ok(Box::new(SystemdServiceManager::new()))
|
Ok(Box::new(SystemdServiceManager::new()))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
|
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
|
||||||
{
|
{
|
||||||
Err(ServiceManagerError::Other(
|
Err(ServiceManagerError::Other(
|
||||||
|
Loading…
Reference in New Issue
Block a user