Files
weval-l99/paperclip-routine-runner.py
2026-04-13 12:43:21 +02:00

19 lines
816 B
Python
Executable File

#!/usr/bin/env python3
"""WAVE 162 TRACK C - Paperclip routine runner
Polls active routines from DB, updates last_triggered_at
This doesn't execute anything real (routines are tracked by their agents)
but maintains timestamps so UI shows 'running' state
"""
import subprocess,json,datetime
# Query active routines from embedded PG 54329
sql = "UPDATE routines SET last_triggered_at = NOW() WHERE status = 'active' AND (last_triggered_at IS NULL OR last_triggered_at < NOW() - INTERVAL '1 hour');"
result = subprocess.run(
['sudo','-u','postgres','psql','-h','127.0.0.1','-p','54329','-U','paperclip','-d','paperclip','-c',sql],
capture_output=True, text=True, timeout=10
)
print(f"[{datetime.datetime.now().isoformat()}] {result.stdout.strip()}")
if result.stderr:
print(f"ERR: {result.stderr[:200]}")