Major additions:
- wrike_monitor.py: Real-time folder monitoring with watchdog
- Daily email reports at 7PM with comprehensive statistics
- Failed file handling with error logs
- Periodic scanning for missed files
- systemd service support for production deployment
- Sequential processing to prevent race conditions
- Proper parent/child folder matching using childIds
Configuration:
- Easy path configuration for local/production
- Configurable Wrike space ID
- Email settings for daily reports
- Auto-cleanup of processed files (24h retention)
Documentation:
- INSTALLATION.md: Complete systemd service setup guide
- QUICKSTART.md: Quick reference for both tools
- Updated README.md with tool comparison
- requirements.txt with clear dependencies
Bug fixes:
- Fixed duplicate folder/project creation via childIds matching
- Added logging for skipped deliverables
- Improved cache management
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
7.2 KiB
7.2 KiB
Wrike Monitor Installation Guide
Overview
This guide covers installing wrike_monitor.py as a systemd service that runs automatically on server boot, monitors a folder 24/7, and sends daily email reports at 7PM.
For simple batch processing, use wrike_import.py instead (no installation needed, just run it).
Prerequisites
- Python 3.6+
- Root/sudo access
- Wrike API token with write permissions
Installation Steps
1. Install Python Dependencies
pip3 install -r requirements.txt
Or manually:
pip3 install requests watchdog schedule
2. Configure the Script
Edit wrike_monitor.py and update the Config class (starting at line 36):
A. Set Paths (Lines 41-44)
For Local Testing:
HOT_FOLDER = Path("/Users/daveporter/Desktop/CODING-2024/Wrike/json_files")
PROCESSED_FOLDER = Path("/Users/daveporter/Desktop/CODING-2024/Wrike/Processed")
FAILED_FOLDER = Path("/Users/daveporter/Desktop/CODING-2024/Wrike/Processed/Failed")
REPORTS_DIR = Path("/Users/daveporter/Desktop/CODING-2024/Wrike/Processed/reports")
For Production Server:
HOT_FOLDER = Path("/data/PRODUCTION/WRIKE_JSON")
PROCESSED_FOLDER = Path("/data/PRODUCTION/WRIKE_JSON/Processed")
FAILED_FOLDER = Path("/data/PRODUCTION/WRIKE_JSON/Failed")
REPORTS_DIR = Path("/PRODUCTION/WRIKE_LOGS")
B. Set Wrike Space (Lines 52-53)
For Staging:
WRIKE_SPACE_ID = "MQAAAABpz7l_"
WRIKE_SPACE_NAME = "Staging"
For Production:
WRIKE_SPACE_ID = "MQAAAABoHcTY"
WRIKE_SPACE_NAME = "LGL Team"
C. Update Email Settings (Lines 79, 84)
REPORT_EMAILS = ["your-email@oliver.agency", "another@oliver.agency"]
DAILY_REPORT_TIME = "19:00" # 7PM daily report
D. Update API Token (Line 49)
WRIKE_TOKEN = "your_production_api_token_here"
3. Copy Files to Server
# Create directory
sudo mkdir -p /root/wrike-import
sudo chmod 755 /root/wrike-import
# Copy script
sudo cp wrike_monitor.py /root/wrike-import/
sudo chmod +x /root/wrike-import/wrike_monitor.py
# Create required directories
sudo mkdir -p /data/PRODUCTION/WRIKE_JSON
sudo mkdir -p /data/PRODUCTION/WRIKE_JSON/Processed
sudo mkdir -p /data/PRODUCTION/WRIKE_JSON/Failed
sudo mkdir -p /PRODUCTION/WRIKE_LOGS
sudo chmod -R 777 /data/PRODUCTION/WRIKE_JSON
sudo chmod -R 777 /PRODUCTION/WRIKE_LOGS
4. Install systemd Service
# Copy service file
sudo cp wrike-monitor.service /etc/systemd/system/
# Reload systemd
sudo systemctl daemon-reload
# Enable service (start on boot)
sudo systemctl enable wrike-monitor
# Start service
sudo systemctl start wrike-monitor
5. Verify Installation
# Check service status
sudo systemctl status wrike-monitor
# View real-time logs
sudo journalctl -u wrike-monitor -f
# Check if monitoring is working
echo '{"test": "data"}' > /data/PRODUCTION/WRIKE_JSON/test.json
sudo journalctl -u wrike-monitor -f
Service Management Commands
Check Status
sudo systemctl status wrike-monitor
Start Service
sudo systemctl start wrike-monitor
Stop Service
sudo systemctl stop wrike-monitor
Restart Service
sudo systemctl restart wrike-monitor
View Logs
# Live tail
sudo journalctl -u wrike-monitor -f
# Last 100 lines
sudo journalctl -u wrike-monitor -n 100
# Since today
sudo journalctl -u wrike-monitor --since today
# Specific time range
sudo journalctl -u wrike-monitor --since "2025-10-09 09:00" --until "2025-10-09 17:00"
Disable Service
sudo systemctl disable wrike-monitor
sudo systemctl stop wrike-monitor
Configuration Changes
After modifying wrike_monitor.py:
# Restart service to apply changes
sudo systemctl restart wrike-monitor
# Verify it started correctly
sudo systemctl status wrike-monitor
Troubleshooting
Service Won't Start
- Check Python path:
which python3
# Update ExecStart in wrike-monitor.service if different
- Check file permissions:
ls -la /root/wrike-import/wrike_monitor.py
sudo chmod +x /root/wrike-import/wrike_monitor.py
- Check logs:
sudo journalctl -u wrike-monitor -n 50
No Files Being Processed
- Verify folder exists and has correct permissions:
ls -la /data/PRODUCTION/WRIKE_JSON
sudo chmod 777 /data/PRODUCTION/WRIKE_JSON
- Test manually:
sudo systemctl stop wrike-monitor
cd /root/wrike-import
python3 wrike_monitor.py
# Watch for errors, then Ctrl+C
sudo systemctl start wrike-monitor
Email Reports Not Sending
- Check SMTP credentials in Config class
- Verify email addresses in
REPORT_EMAILS - Check logs for email errors:
sudo journalctl -u wrike-monitor | grep -i email
High CPU/Memory Usage
- Reduce batch size and workers in Config:
BATCH_SIZE = 3
MAX_WORKERS = 3
- Increase scan interval:
PERIODIC_SCAN_INTERVAL = 120 # Scan every 2 minutes instead of 1
Testing Before Production
Local Testing
- Keep local paths in Config
- Run manually:
python3 wrike_monitor.py
- Drop test JSON files into the hot folder
- Verify they're processed and moved to Processed/
Server Testing (without service)
# Run in foreground
sudo python3 /root/wrike-import/wrike_monitor.py
# Test file processing
sudo cp test.json /data/PRODUCTION/WRIKE_JSON/
# Watch logs
# Ctrl+C to stop when satisfied
Monitoring Production
Check Daily Reports
# View today's report
cat /PRODUCTION/WRIKE_LOGS/daily_report_$(date +%Y-%m-%d).txt
# List all reports
ls -lh /PRODUCTION/WRIKE_LOGS/
Monitor Performance
# View stats every minute (in logs)
sudo journalctl -u wrike-monitor -f | grep "📊"
# Check for errors
sudo journalctl -u wrike-monitor | grep -i error
# Check for slow scans
sudo journalctl -u wrike-monitor | grep -i "slow"
Check Processed/Failed Files
# Processed files (will auto-delete after 24h)
ls -lh /data/PRODUCTION/WRIKE_JSON/Processed/
# Failed files (need manual review)
ls -lh /data/PRODUCTION/WRIKE_JSON/Failed/
# View error logs
cat /data/PRODUCTION/WRIKE_JSON/Failed/*_ERROR.txt
Maintenance
Manually Trigger Daily Report
# The report runs automatically at 7PM, but to test:
sudo systemctl restart wrike-monitor
# Then wait or modify DAILY_REPORT_TIME in config
Clear Failed Files After Review
# After reviewing and fixing failed files
sudo rm -rf /data/PRODUCTION/WRIKE_JSON/Failed/*
Backup Configuration
# Backup before changes
sudo cp /root/wrike-import/wrike_monitor.py /root/wrike-import/wrike_monitor.py.backup
Uninstallation
# Stop and disable service
sudo systemctl stop wrike-monitor
sudo systemctl disable wrike-monitor
# Remove service file
sudo rm /etc/systemd/system/wrike-monitor.service
sudo systemctl daemon-reload
# Remove script (optional)
sudo rm -rf /root/wrike-import
# Remove data directories (optional - be careful!)
# sudo rm -rf /data/PRODUCTION/WRIKE_JSON
# sudo rm -rf /PRODUCTION/WRIKE_LOGS
Support
For issues:
- Check logs:
sudo journalctl -u wrike-monitor -f - Verify configuration in
wrike_monitor.py - Test manually before running as service
- Review daily reports for patterns
Last Updated: October 2025