From 2e88321aecfd1c4a7fa69a1794ecdf34a401c358 Mon Sep 17 00:00:00 2001 From: Nemo157 Date: Sat, 25 May 2024 14:03:55 +0200 Subject: feat: support systemd socket activation for daemon (#2039) This avoids issues with clients attempting to connect to the daemon while it's starting, systemd creates the socket early and will queue connections up until the daemon is ready to accept them. --- crates/atuin-client/config.toml | 5 +++++ crates/atuin-client/src/settings.rs | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'crates/atuin-client') diff --git a/crates/atuin-client/config.toml b/crates/atuin-client/config.toml index 49e06c45..4938991a 100644 --- a/crates/atuin-client/config.toml +++ b/crates/atuin-client/config.toml @@ -223,5 +223,10 @@ records = true ## windows: Not Supported # socket_path = "~/.local/share/atuin/atuin.sock" +## Use systemd socket activation rather than opening the given path (the path must still be correct for the client) +## linux: false +## mac/windows: Not Supported +# systemd_socket = false + ## The port that should be used for TCP on non unix systems # tcp_port = 8889 diff --git a/crates/atuin-client/src/settings.rs b/crates/atuin-client/src/settings.rs index a97d05eb..f4434e41 100644 --- a/crates/atuin-client/src/settings.rs +++ b/crates/atuin-client/src/settings.rs @@ -350,6 +350,9 @@ pub struct Daemon { /// The path to the unix socket used by the daemon pub socket_path: String, + /// Use a socket passed via systemd's socket activation protocol, instead of the path + pub systemd_socket: bool, + /// The port that should be used for TCP on non unix systems pub tcp_port: u64, } @@ -368,6 +371,7 @@ impl Default for Daemon { enabled: false, sync_frequency: 300, socket_path: "".to_string(), + systemd_socket: false, tcp_port: 8889, } } @@ -715,6 +719,7 @@ impl Settings { .set_default("daemon.sync_frequency", 300)? .set_default("daemon.enabled", false)? .set_default("daemon.socket_path", socket_path.to_str())? + .set_default("daemon.systemd_socket", false)? .set_default("daemon.tcp_port", 8889)? .set_default( "prefers_reduced_motion", -- cgit v1.3.1