mirror of
https://github.com/atuinsh/atuin.git
synced 2026-10-12 02:11:09 +00:00
fix: restart the daemon when enabling output capture (#4215)
<!-- Thank you for making a PR! Bug fixes are always welcome, but if you're adding a new feature or changing an existing one, we'd really appreciate if you open an issue, post on the forum, or drop in on Discord --> ## Checks - [ ] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [ ] I have checked that there are no existing pull requests for the same thing
This commit is contained in:
@@ -4,6 +4,9 @@ use eyre::Result;
|
||||
use toml_edit::{Document, DocumentMut, Item, Table, TableLike, Value};
|
||||
use tracing::instrument;
|
||||
|
||||
#[cfg(feature = "daemon")]
|
||||
use crate::command::client::daemon;
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
#[command(infer_subcommands = true)]
|
||||
pub enum Cmd {
|
||||
@@ -250,7 +253,22 @@ impl EnableCmd {
|
||||
let updated = self.get_updated_config(&config_str, settings.daemon.enabled)?;
|
||||
tokio::fs::write(&config_file, &updated).await?;
|
||||
|
||||
println!("Enabled. Restart your shell for the change to take effect.");
|
||||
println!("Enabled.");
|
||||
|
||||
// The daemon reads these settings only at startup, so it needs a restart to pick them
|
||||
// up. A running daemon with autostart off may be externally managed (systemd, launchd),
|
||||
// so leave that one alone and tell the user instead.
|
||||
#[cfg(feature = "daemon")]
|
||||
if settings.daemon.enabled && !settings.daemon.autostart {
|
||||
println!("Restart the Atuin daemon and your shell for the change to take effect.");
|
||||
return Ok(());
|
||||
} else if let Err(e) = daemon::restart_cmd(settings).await {
|
||||
eprintln!(
|
||||
"Could not restart the Atuin daemon: {e}\nRun `atuin daemon restart` manually."
|
||||
);
|
||||
}
|
||||
|
||||
println!("Restart your shell for the change to take effect.");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ async fn stop_cmd(settings: &Settings) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
async fn restart_cmd(settings: &Settings) -> Result<()> {
|
||||
pub(super) async fn restart_cmd(settings: &Settings) -> Result<()> {
|
||||
// Stop if running
|
||||
match probe(settings).await {
|
||||
Probe::Ready(_) | Probe::NeedsRestart(_) => {
|
||||
|
||||
Reference in New Issue
Block a user