matrix daemon: stay up when the primary account is down and say why in the tools
This commit is contained in:
parent
9fdde2ec63
commit
73ef63a5e5
1 changed files with 159 additions and 81 deletions
|
|
@ -97,9 +97,9 @@ in
|
|||
(for `main`, a file only when the store has no token: the
|
||||
swarm mints `main` into the store; an operator-supplied
|
||||
secret for an external one). The daemon
|
||||
leaves an extra account whose token is absent down and tries
|
||||
it again every few minutes, and
|
||||
exits cleanly to wait on the path watcher when `main`'s is.
|
||||
leaves an account whose token is absent down and tries
|
||||
it again every few minutes, answering its tool calls with
|
||||
why it is down meanwhile; it stays up when `main`'s is.
|
||||
'';
|
||||
};
|
||||
sessionDir = lib.mkOption {
|
||||
|
|
@ -384,14 +384,10 @@ in
|
|||
serviceConfig = {
|
||||
ExecStart = "${config.services.hyperhive.agent.packages.hive-matrix-daemon}/bin/hive-matrix-daemon --http 127.0.0.1:${toString config.services.hyperhive.agent.mcp.matrixHttpPort}";
|
||||
SyslogIdentifier = "hive-matrix-daemon";
|
||||
# `on-failure`, not `always`: the daemon deliberately exits 0
|
||||
# (a clean, non-failure exit) when no token is provisioned yet
|
||||
# (see the module doc above) — the `systemd.paths` watcher
|
||||
# below re-fires it the moment a token file appears (the timer
|
||||
# above, for a token in the store),
|
||||
# instead of `always` busy-looping every `RestartSec` until
|
||||
# then. Once a token exists this is no different from
|
||||
# `hive-bash-daemon`'s reasoning (a down window loses the MCP
|
||||
# `on-failure`, not `always`: a clean exit is deliberate (the
|
||||
# daemon stays up when no token is provisioned or the homeserver
|
||||
# is down, and retries the account itself). This is no different
|
||||
# from `hive-bash-daemon`'s reasoning (a down window loses the MCP
|
||||
# tools with no stdio fallback) — a genuine crash is a
|
||||
# non-zero exit, which `on-failure` already restarts.
|
||||
Restart = "on-failure";
|
||||
|
|
@ -420,8 +416,9 @@ in
|
|||
|
||||
# Re-start the daemon while it is down, when its token lives in the store.
|
||||
# The path unit below only sees files, and a token the swarm mints or
|
||||
# replaces in the store changes no file: a daemon that exited on a missing
|
||||
# or replaced token would otherwise stay down until the container restarts.
|
||||
# replaces in the store changes no file: a daemon that went down
|
||||
# (crash, or the exit 75 below) would otherwise stay down until the
|
||||
# container restarts.
|
||||
# Relative to the daemon's last exit, so it never fires while the daemon
|
||||
# runs; five minutes is the swarm's own re-mint cadence.
|
||||
systemd.timers.hive-matrix-daemon = lib.mkIf (matrixEnabled && storeConfigured) {
|
||||
|
|
@ -431,9 +428,8 @@ in
|
|||
};
|
||||
|
||||
# Re-fire the daemon when a matrix token file appears (a declared
|
||||
# `tokenFile`, or a `main` from before the swarm minted it). Without this
|
||||
# the daemon would exit 0 silently on first boot and the MCP
|
||||
# would have no backend until next restart. See
|
||||
# `tokenFile`, or a `main` from before the swarm minted it) so the daemon
|
||||
# picks it up at once instead of on its next two-minute retry. See
|
||||
# `docs/4-implementation/agent-state/persistence.md` (same section as above).
|
||||
systemd.paths.hive-matrix-daemon = lib.mkIf matrixEnabled {
|
||||
description = "trigger hive-matrix-daemon when a matrix token appears";
|
||||
|
|
@ -443,12 +439,9 @@ in
|
|||
#
|
||||
# ⚠️ This agent's own state dir, not a glob over `/agents/*/`. Every
|
||||
# agent's state dir is visible from inside every container, so a
|
||||
# wildcard is satisfied by a sibling's token — and this daemon exits 0
|
||||
# when it has no token of its own (see `Restart = "on-failure"`
|
||||
# above), so the unit deactivates, the path unit re-arms, the
|
||||
# sibling's token still matches, and it fires again until the start
|
||||
# limit stops it. Scoped to this agent, the condition is false exactly
|
||||
# when the daemon would have nothing to do.
|
||||
# wildcard is satisfied by a sibling's token, so it would restart a
|
||||
# daemon that has none of its own. Scoped to this agent, the condition
|
||||
# is false exactly when the daemon would have nothing to do.
|
||||
pathConfig.PathExistsGlob = "${stateDir}/matrix-token*";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue