Commit graph

16 commits

Author SHA1 Message Date
Niko Marmeladkov
032f0ded69
auto-discover daemon state dir from /proc when RSS_STATE_DIR is unset 2026-07-06 10:43:56 +03:00
Niko Marmeladkov
27c3d339c6
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.
2026-07-05 22:31:48 +03:00
Niko Marmeladkov
00eb7cdd24 attach: add -f alias for --full 2026-07-03 17:36:31 +03:00
Niko Marmeladkov
a4ae0b21db rss attach: send commands to service stdin
- rss send <name> <message>: one-line command to service stdin
- rss attach <name>: interactive stdin forwarding with log tailing
- rss attach --full <name>: same but Ctrl+C sends SIGINT
- safe mode: Ctrl+C just detaches, doesn't kill the process
- Ctrl+P then D to detach
- daemon stores ChildStdin in Proc, handles streaming stdin IPC
2026-07-03 17:32:09 +03:00
Niko Marmeladkov
672b676020 multi-service commands: rss start/stop/restart/enable/disable mc-proxy mc-lobby
supports space-separated service names in start, stop, restart,
enable, disable commands. each service result returned on its own line.
2026-07-03 15:33:01 +03:00
Niko Marmeladkov
f0d334b7dd children die when rss dies via PR_SET_PDEATHSIG
sets SIGTERM death signal in each child before exec, so if the
daemon exits (even by crash/SIGKILL), all managed services receive
SIGTERM and terminate. adds libc dependency for prctl.

includes getppid() == 1 check to handle the fork/prctl race.
2026-07-03 14:15:38 +03:00
Niko Marmeladkov
a92768157c
fix hardcoded HOME paths in stop() and check_children()
Both functions used format! with HOME for log paths; when daemon
runs as system user without HOME, logs went to /.local/share/...
Now uses state::log_path() like spawn() does.
2026-07-03 14:10:05 +03:00
Niko Marmeladkov
541e3b09ed
enable/disable via daemon IPC, not local config
CLI now sends enable/disable commands to the daemon via Unix
socket. The daemon validates the service against its config,
creates/removes the enabled marker, and optionally starts the
service (enable --now). CLI no longer needs config access.
2026-07-03 13:27:40 +03:00
Niko Marmeladkov
6a1c59f91a
fix socket permissions and ipc cleanup bug
- daemon: chmod socket to 0770 after bind so group devs can connect
- ipc: remove stale-socket deletion — it was deleting the socket when
  connect failed due to permissions, breaking the running daemon
2026-07-03 13:21:40 +03:00
Niko Marmeladkov
17f52e31ca
graceful startup errors instead of panics
- bind socket: eprintln instead of expect (exit 0, not 101)
- write_pid, create_dir_all, set_permissions: check errors
- all errors print to stderr and return cleanly
2026-07-03 13:14:54 +03:00
Niko Marmeladkov
38882b70c3
default to /tmp/rss/ for shared multi-user access
- runtime_dir() defaults to /tmp/rss (no user-specific fallback)
- socket_path() defaults to /tmp/rss/rss.sock (overridable via RSS_SOCKET)
- enabled markers in runtime_dir, not config_dir (shared state)
- daemon creates /tmp/rss/ with explicit 770 permissions
2026-07-03 13:10:08 +03:00
Niko Marmeladkov
7383445ea5
refactor paths: remove HOME dependency, use env/XDG/tmp fallback
- socket/log/enabled paths resolved via state.rs with priority:
  RSS_SOCKET/RSS_STATE_DIR/RSS_CONFIG_DIR env → XDG_RUNTIME_DIR
  → ~/.local/share/rss → /tmp/rss-niko
- config path: RSS_CONFIG → RSS_CONFIG_DIR/config.toml → ~/.config/rss
  → /etc/rss/config.toml
- removed State struct; all functions are module-level
- daemon chmods socket parent dir for group access
- clean up stale PID file on config load failure
2026-07-03 13:04:58 +03:00
Niko Marmeladkov
b069c527bd
daemon: centralized architecture with Unix socket IPC
- single daemon process manages all services in memory
- CLI communicates via Unix socket, does not read config
- config hot-reload: daemon polls config.toml, reacts immediately
- rename-safe: removing a service from config kills it, adding starts if enabled
- logs remain file-based for direct reading by rss logs
- removed per-service PID files, supervisor module simplified
2026-07-03 11:49:46 +03:00
Niko Marmeladkov
a7ce8405d1
centralize: daemon syncs state with config, cleanup orphans
- rss daemon kills and cleans services not in config (rename-safe)
- rss list also prunes orphaned state
- rss start checks for already running before spawning
- State: add supervise_dir/service_dir/list_pid_names helpers
2026-07-03 11:20:36 +03:00
Niko Marmeladkov
74b9539149
add unless-stopped restart policy, systemd user unit, readme 2026-07-03 11:01:59 +03:00
Niko Marmeladkov
653b8d1612
initial: per-user process supervisor (rss)
- start/stop/restart/status/logs/enable/disable/list/daemon
- PID-file based state, no daemon, no root
- config.toml with placeholders, restart policies, env vars
- log tailing with -n/-f and stderr colorization
- supervisor per service with SIGTERM handling
2026-07-03 10:47:25 +03:00