aboutsummaryrefslogtreecommitdiff
path: root/src/server/autodetect.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-31 03:02:45 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-31 03:04:20 +0300
commit77819797385c5538f624a8881208921342911db0 (patch)
tree931a03aa3825a10d6b6d73b63e4ce80e19ecbf56 /src/server/autodetect.rs
parent3acd499ffb1119e8032bbcba3f1f46d4ff5f3da9 (diff)
fix: clarify update restart guidance
Diffstat (limited to 'src/server/autodetect.rs')
-rw-r--r--src/server/autodetect.rs28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/server/autodetect.rs b/src/server/autodetect.rs
index c278329d..c012aa03 100644
--- a/src/server/autodetect.rs
+++ b/src/server/autodetect.rs
@@ -85,11 +85,10 @@ fn read_server_status() -> io::Result<Option<crate::api::RuntimeStatus>> {
}
fn validate_running_server_compatibility() -> io::Result<()> {
- let stop_command = crate::session::local_stop_command();
- let attach_command = crate::session::local_attach_command();
let Some(status) = read_server_status()? else {
return Err(io::Error::other(format!(
- "a herdr server is listening, but its status API is unavailable. Try `{stop_command}`; if that fails, stop the old server process manually, then run `{attach_command}` again."
+ "a herdr server is listening, but its status API is unavailable.\n\n{}\nIf that fails, stop the old server process manually.",
+ crate::session::active_restart_after_update_guidance()
)));
};
@@ -98,14 +97,15 @@ fn validate_running_server_compatibility() -> io::Result<()> {
}
Err(io::Error::other(format!(
- "herdr server is running from v{} / protocol {}, but this client is v{} / protocol {}.\nStop the old server with `{stop_command}`, then run `{attach_command}` again.",
+ "Herdr was updated, but this session is still running the old server.\n\nserver: v{} protocol {}\nclient: v{} protocol {}\n\n{}",
status.version.as_deref().unwrap_or("unknown"),
status
.protocol
.map(|value| value.to_string())
.unwrap_or_else(|| "unknown".to_string()),
env!("CARGO_PKG_VERSION"),
- crate::protocol::PROTOCOL_VERSION
+ crate::protocol::PROTOCOL_VERSION,
+ crate::session::active_restart_after_update_guidance()
)))
}
@@ -432,12 +432,13 @@ mod tests {
fn validate_running_server_compatibility_names_session_commands_for_protocol_mismatch() {
let _guard = env_lock().lock().unwrap();
let dir = unique_test_dir("named-protocol");
- std::fs::create_dir_all(&dir).unwrap();
- let path = dir.join("api.sock");
- let listener = UnixListener::bind(&path).unwrap();
- std::env::set_var(crate::api::SOCKET_PATH_ENV_VAR, &path);
+ std::env::set_var("XDG_CONFIG_HOME", &dir);
std::env::set_var(crate::session::SESSION_ENV_VAR, "work");
+ std::env::remove_var(crate::api::SOCKET_PATH_ENV_VAR);
crate::session::clear_explicit_session_for_test();
+ let path = crate::session::api_socket_path_for(Some("work"));
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ let listener = UnixListener::bind(&path).unwrap();
let handle = std::thread::spawn(move || {
let (mut stream, _) = listener.accept().unwrap();
let mut request = String::new();
@@ -458,15 +459,20 @@ mod tests {
let _ = handle.join();
assert!(
- message.contains("Stop the old server with `herdr session stop work`"),
+ message.contains("Stop the old server to use the new version"),
+ "unexpected error: {message}"
+ );
+ assert!(
+ message.contains("Run `herdr session stop work`"),
"unexpected error: {message}"
);
assert!(
message.contains("then run `herdr session attach work` again"),
"unexpected error: {message}"
);
- std::env::remove_var(crate::api::SOCKET_PATH_ENV_VAR);
+ std::env::remove_var("XDG_CONFIG_HOME");
std::env::remove_var(crate::session::SESSION_ENV_VAR);
+ std::env::remove_var(crate::api::SOCKET_PATH_ENV_VAR);
crate::session::clear_explicit_session_for_test();
let _ = std::fs::remove_dir_all(dir);
}