hvac-kia-content/monitor_backlog.py
Ben Reed 05218a873b Fix critical production issues and improve spec compliance
Production Readiness Improvements:
- Fixed scheduling to match spec (8 AM & 12 PM ADT instead of 6 AM/6 PM)
- Enabled NAS synchronization in production runner with error handling
- Fixed file naming convention to spec format (hvacknowitall_combined_YYYY-MM-DD-THHMMSS.md)
- Made systemd services portable (removed hardcoded user/paths)
- Added environment variable validation on startup
- Moved DISPLAY/XAUTHORITY to .env configuration

Systemd Improvements:
- Created template service file (@.service) for any user
- Changed all paths to /opt/hvac-kia-content
- Updated installation script for portable deployment
- Fixed service dependencies and resource limits

Documentation:
- Created comprehensive PRODUCTION_TODO.md with 25 tasks
- Added PRODUCTION_GUIDE.md with deployment instructions
- Documented spec compliance gaps (65% complete)

Remaining work includes retry logic, connection pooling, media downloads,
and pytest test suite as documented in PRODUCTION_TODO.md

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 20:07:55 -03:00

70 lines
No EOL
2.2 KiB
Python

#!/usr/bin/env python3
"""
Monitor backlog processing progress by checking logs and output files.
"""
import time
import os
from pathlib import Path
from datetime import datetime
def check_log_progress():
"""Check progress from log files."""
log_dir = Path("test_logs/backlog")
sources = ["Wordpress", "Instagram", "Mailchimp", "Podcast", "Youtube", "Tiktok"]
print(f"\n{'='*60}")
print(f"BACKLOG PROGRESS CHECK - {datetime.now().strftime('%H:%M:%S')}")
print(f"{'='*60}")
for source in sources:
log_file = log_dir / source / f"{source.lower()}.log"
if log_file.exists():
# Get file size and recent lines
size_mb = log_file.stat().st_size / (1024 * 1024)
# Read last 10 lines
try:
with open(log_file, 'r', encoding='utf-8') as f:
lines = f.readlines()
recent_lines = lines[-3:] if len(lines) >= 3 else lines
print(f"\n{source}:")
print(f" Log size: {size_mb:.2f} MB")
print(f" Recent activity:")
for line in recent_lines:
print(f" {line.strip()}")
except Exception as e:
print(f"\n{source}: Error reading log - {e}")
else:
print(f"\n{source}: No log file yet")
def check_output_files():
"""Check generated markdown files."""
data_dir = Path("test_data/backlog")
print(f"\n{'='*30}")
print("GENERATED FILES:")
print(f"{'='*30}")
if data_dir.exists():
markdown_files = list(data_dir.glob("*.md"))
print(f"Total markdown files: {len(markdown_files)}")
for file in sorted(markdown_files):
size_kb = file.stat().st_size / 1024
print(f" {file.name}: {size_kb:.1f} KB")
else:
print("No output directory yet")
if __name__ == "__main__":
try:
check_log_progress()
check_output_files()
print(f"\n{'='*60}")
print("Monitoring continues... Use Ctrl+C to stop")
print(f"{'='*60}")
except KeyboardInterrupt:
print("\nMonitoring stopped.")
except Exception as e:
print(f"Error: {e}")