Documentation Added: - ARCHITECTURE_DECISIONS.md: Explains why systemd over k8s (TikTok display requirements) - DEPLOYMENT_CHECKLIST.md: Step-by-step deployment procedures - ROLLBACK_PROCEDURES.md: Emergency rollback and recovery procedures - test_production_deployment.py: Automated deployment verification script Key Documentation Highlights: - Detailed explanation of containerization limitations with browser automation - Complete deployment checklist with pre/post verification steps - Rollback scenarios with recovery time objectives - Emergency contact templates and backup procedures - Automated test script for production readiness 17 of 25 tasks completed (68% done) Remaining work focuses on spec compliance and testing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
6.7 KiB
6.7 KiB
Production Deployment Checklist
Pre-Deployment Verification
Environment Setup
- Ubuntu 20.04+ or compatible Linux distribution
- Python 3.9+ installed
- 2GB+ RAM available
- 10GB+ disk space available
- Display server running (for TikTok scraping)
- Network connectivity to all target sites
Dependencies
- Install system packages:
sudo apt update sudo apt install python3-pip python3-venv git chromium-browser - Install Python packages:
pip install -r requirements.txt - Verify Chromium browser works:
chromium-browser --version
Configuration Files
-
.envfile created with all required variables:- WORDPRESS_USERNAME
- WORDPRESS_API_KEY
- YOUTUBE_CHANNEL_URL
- INSTAGRAM_USERNAME
- INSTAGRAM_PASSWORD
- TIKTOK_TARGET
- NAS_PATH
- TIMEZONE (default: America/Halifax)
- HEALTHCHECK_URL (optional)
- ALERT_EMAIL (optional)
-
.envfile permissions set to 600:chmod 600 .env
Directory Structure
- Create production directories:
sudo mkdir -p /opt/hvac-kia-content sudo mkdir -p /var/log/hvac-content - Set proper ownership:
sudo chown -R $USER:$USER /opt/hvac-kia-content sudo chown -R $USER:$USER /var/log/hvac-content
NAS Configuration
- NAS mount point exists and is accessible
- Write permissions verified:
touch /mnt/nas/hvacknowitall/test.txt && rm /mnt/nas/hvacknowitall/test.txt - Sufficient space available on NAS
Deployment Steps
1. Code Deployment
- Clone repository to staging location:
git clone https://github.com/yourusername/hvac-kia-content.git cd hvac-kia-content - Checkout correct branch/tag:
git checkout main # or specific version tag
2. Configuration
- Copy
.env.exampleto.env:cp .env.example .env - Edit
.envwith production values - Verify environment variables:
python3 -c "from run_production import validate_environment; validate_environment()"
3. Test Individual Scrapers
- Test WordPress:
python test_real_data.py --source wordpress --items 1 - Test YouTube:
python test_real_data.py --source youtube --items 1 - Test Instagram (carefully):
python test_real_data.py --source instagram --items 1 - Test TikTok:
DISPLAY=:0 python test_real_data.py --source tiktok --items 1 - Test MailChimp RSS:
python test_real_data.py --source mailchimp --items 1 - Test Podcast RSS:
python test_real_data.py --source podcast --items 1
4. Test Production Runner
- Dry run test:
python run_production.py --job regular --dry-run - Verify output file created
- Check log files for errors
- Verify NAS sync (if enabled)
5. Install Systemd Services
- Run installation script:
chmod +x install_production.sh ./install_production.sh - Verify services installed:
systemctl list-unit-files | grep hvac
6. Enable Services
- Enable main timer:
sudo systemctl enable hvac-content-aggregator.timer - Start timer:
sudo systemctl start hvac-content-aggregator.timer - Verify timer is active:
systemctl status hvac-content-aggregator.timer
7. Optional: TikTok Captions
- Only if captions are required:
sudo systemctl enable hvac-tiktok-captions.timer sudo systemctl start hvac-tiktok-captions.timer
Post-Deployment Verification
Immediate Checks
- Timer scheduled correctly:
systemctl list-timers | grep hvac - No errors in service status:
systemctl status hvac-content-aggregator.service - Log files being created:
ls -la /var/log/hvac-content/
First Run Verification
- Manually trigger first run:
sudo systemctl start hvac-content-aggregator.service - Monitor logs in real-time:
tail -f /var/log/hvac-content/aggregator.log - Verify all sources processed
- Check output file created
- Verify NAS sync completed
- Health check ping received (if configured)
24-Hour Verification
- Check timer fired at scheduled times (8 AM, 12 PM)
- Review metrics.json for performance data
- Check disk usage:
df -h /opt/hvac-kia-content - Review error logs:
grep ERROR /var/log/hvac-content/*.log - Verify incremental updates working (no duplicates)
Monitoring Setup
Log Monitoring
- Set up log rotation if needed:
sudo nano /etc/logrotate.d/hvac-content/var/log/hvac-content/*.log { daily rotate 7 compress missingok notifempty }
Health Monitoring
- Configure health check service (e.g., Healthchecks.io)
- Set up email alerts for failures
- Create dashboard for metrics visualization
Backup Configuration
- Schedule state file backups:
0 2 * * * tar -czf /backup/hvac-state-$(date +\%Y\%m\%d).tar.gz /opt/hvac-kia-content/state/ - Test restore procedure
Troubleshooting Checklist
If Scrapers Fail
- Check environment variables are set
- Verify network connectivity
- Check API rate limits
- Review authentication credentials
- Check display server (for TikTok)
If Timer Doesn't Fire
- Check timer is enabled
- Verify system time is correct
- Check systemd timer status
- Review journal logs:
journalctl -u hvac-content-aggregator.timer
If NAS Sync Fails
- Verify NAS is mounted
- Check write permissions
- Verify sufficient space
- Test rsync manually
Rollback Procedure
Quick Rollback
- Stop services:
sudo systemctl stop hvac-content-aggregator.timer - Restore previous version:
cd /opt/hvac-kia-content git checkout <previous-version> - Restart services:
sudo systemctl start hvac-content-aggregator.timer
Full Rollback
- Stop and disable all services
- Restore backup of state files
- Restore previous code version
- Re-run installation script
- Verify functionality
- Re-enable services
Sign-off
- Deployment completed successfully
- All verification steps passed
- Monitoring configured
- Documentation updated
- Team notified
Deployed By: _________________
Date: _________________
Version: _________________
Notes: _________________
Last Updated: 2024-12-18