From 27c3d339c6f92f6277620e06210ccc52c3cf0025 Mon Sep 17 00:00:00 2001 From: Niko Marmeladkov Date: Sun, 5 Jul 2026 22:31:48 +0300 Subject: [PATCH] add --state-dir (-D) flag to persist enabled/logs/pid across reboots socket stays in /tmp/rss/rss.sock so client commands need no extra args; state dir is controlled by RSS_STATE_DIR or --state-dir and stores enabled flags, logs, and daemon.pid in a persistent location. --- src/cli.rs | 3 +++ src/main.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index 42795c7..4510c12 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -6,6 +6,9 @@ pub struct Cli { #[arg(short = 'C', long, global = true, help = "Path to config file")] pub config: Option, + #[arg(short = 'D', long, global = true, help = "Path to state directory (default: /tmp/rss or $RSS_STATE_DIR)")] + pub state_dir: Option, + #[command(subcommand)] pub command: Commands, } diff --git a/src/main.rs b/src/main.rs index cc56a34..3a7951b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,10 @@ use std::sync::atomic::{AtomicBool, Ordering}; fn main() { let cli = Cli::parse(); + if let Some(ref dir) = cli.state_dir { + std::env::set_var("RSS_STATE_DIR", dir); + } + match cli.command { Commands::Daemon => { let config_path = resolve_config_path(cli.config.as_deref());