feat(tmux): implement 2-hour inactivity session TTL reaper and prune command

This commit is contained in:
operator
2026-10-05 16:23:45 +00:00
parent c13ee20ea4
commit 945e6bb481
4 changed files with 72 additions and 0 deletions
+26
View File
@@ -729,6 +729,27 @@ def _tmux_kill_build(a):
return [sys.executable, os.path.join(BIN_DIR, 'muse-tmux.py'), 'kill', a['session']]
def _tmux_prune_validate(raw):
if not isinstance(raw, dict):
raise OpError('args must be an object')
allowed = {'ttl'}
for k in raw:
if k not in allowed:
raise OpError(f'unknown arg: {k}')
ttl = raw.get('ttl', 7200)
try:
ttl = int(ttl)
if ttl < 60:
ttl = 60
except Exception:
ttl = 7200
return {'ttl': ttl}
def _tmux_prune_build(a):
return [sys.executable, os.path.join(BIN_DIR, 'muse-tmux.py'), 'prune', '--ttl', str(a['ttl'])]
def _vars_list_validate(raw):
if raw not in ({}, None):
raise OpError('vars.list takes no required args')
@@ -1174,6 +1195,11 @@ OPS = {
'timeout': 15, 'side_effecting': True,
'desc': 'Kill a session on shared Muse tmux socket (/tmp/tmux-muse.sock)',
},
'tmux.prune': {
'validate': _tmux_prune_validate, 'build': _tmux_prune_build,
'timeout': 15, 'side_effecting': True,
'desc': 'Reap stale unattached sessions inactive for >TTL (default 2h)',
},
'exec.ping': {
'validate': _health_validate,
'build': lambda a: ['/bin/echo', 'PONG'],