From b61a907bac09a7649ca3f6d850e771b3b75c7015 Mon Sep 17 00:00:00 2001 From: soryu Date: Thu, 22 Jan 2026 01:26:53 +0000 Subject: Add daemon restart feature from settings (#18) * Add daemon restart feature from settings This adds the ability to restart a connected daemon from the settings page. The feature includes: - Backend: RestartDaemon command added to DaemonCommand enum - Backend: New POST /api/v1/mesh/daemons/{id}/restart endpoint - Backend: Daemon gracefully shuts down tasks and exits with code 42 (can be used by process managers like systemd to detect restart requests) - Frontend: restartDaemon() API function - Frontend: Restart button in Connected Daemons section of settings - Frontend: Confirmation dialog before restart to prevent accidental restarts When a daemon receives the restart command, it: 1. Gracefully shuts down all running Claude processes (5s timeout) 2. Exits with code 42 to signal restart requested 3. The daemon can be restarted by a process manager or manually Co-Authored-By: Claude Opus 4.5 --- makima/src/daemon/task/manager.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'makima/src/daemon/task/manager.rs') diff --git a/makima/src/daemon/task/manager.rs b/makima/src/daemon/task/manager.rs index 5eed0e8..a3e4732 100644 --- a/makima/src/daemon/task/manager.rs +++ b/makima/src/daemon/task/manager.rs @@ -1663,6 +1663,15 @@ impl TaskManager { tracing::info!(source_dir = ?source_dir, "Inheriting git config"); self.handle_inherit_git_config(source_dir).await?; } + DaemonCommand::RestartDaemon => { + tracing::info!("Received restart command from server, initiating daemon restart..."); + // Shutdown all running tasks gracefully + self.shutdown_all_processes(std::time::Duration::from_secs(5)).await; + // Exit the process - the daemon should be restarted by a process manager + // or the user can restart it manually + tracing::info!("Daemon restart: exiting process with code 42 (restart requested)"); + std::process::exit(42); + } } Ok(()) } -- cgit v1.2.3