punimtag/QUICK_LOG_REFERENCE.md
tanyar09 7a981b069a
All checks were successful
CI / skip-ci-check (pull_request) Successful in 8s
CI / lint-and-type-check (pull_request) Successful in 1m12s
CI / python-lint (pull_request) Successful in 36s
CI / test-backend (pull_request) Successful in 3m47s
CI / build (pull_request) Successful in 3m28s
CI / secret-scanning (pull_request) Successful in 14s
CI / dependency-scan (pull_request) Successful in 13s
CI / sast-scan (pull_request) Successful in 1m33s
CI / workflow-summary (pull_request) Successful in 5s
feat: Enhance logging and error handling for job streaming and photo uploads
- Added new logging scripts for quick access to service logs and troubleshooting.
- Updated job streaming API to support authentication via query parameters for EventSource.
- Improved photo upload process to capture and validate EXIF dates and original modification times.
- Enhanced error handling for file uploads and EXIF extraction failures.
- Introduced new configuration options in ecosystem.config.js to prevent infinite crash loops.
2026-02-04 19:30:05 +00:00

2.2 KiB

Quick Log Reference

When something fails, use these commands to quickly check logs.

🚀 Quick Commands

Check All Services for Errors

./scripts/check-logs.sh

Shows PM2 status and recent errors from all services.

Follow Errors in Real-Time

./scripts/tail-errors.sh

Watches all error logs live (press Ctrl+C to exit).

View Recent Errors (Last 10 minutes)

./scripts/view-recent-errors.sh

View Errors from Last 30 minutes

./scripts/view-recent-errors.sh 30

📋 PM2 Commands

# View all logs
pm2 logs

# View specific service logs
pm2 logs punimtag-api
pm2 logs punimtag-worker
pm2 logs punimtag-admin
pm2 logs punimtag-viewer

# View only errors
pm2 logs --err

# Monitor services
pm2 monit

# Check service status
pm2 status
pm2 list

📁 Log File Locations

All logs are in: /home/appuser/.pm2/logs/

  • API: punimtag-api-error.log, punimtag-api-out.log
  • Worker: punimtag-worker-error.log, punimtag-worker-out.log
  • Admin: punimtag-admin-error.log, punimtag-admin-out.log
  • Viewer: punimtag-viewer-error.log, punimtag-viewer-out.log

🔧 Direct Log Access

# View last 50 lines of API errors
tail -n 50 /home/appuser/.pm2/logs/punimtag-api-error.log

# Follow worker errors
tail -f /home/appuser/.pm2/logs/punimtag-worker-error.log

# Search for specific errors
grep -i "error\|exception\|traceback" /home/appuser/.pm2/logs/punimtag-*-error.log

🔄 Log Rotation Setup

Run once to prevent log bloat:

./scripts/setup-log-rotation.sh

This configures:

  • Max log size: 50MB (auto-rotates)
  • Retain: 7 rotated files
  • Compress: Yes
  • Daily rotation: Yes (midnight)

💡 Troubleshooting Tips

  1. Service keeps crashing?

    ./scripts/check-logs.sh
    pm2 logs punimtag-worker --err --lines 100
    
  2. API not responding?

    pm2 logs punimtag-api --err
    pm2 status
    
  3. Large log files?

    # Check log sizes
    du -h /home/appuser/.pm2/logs/*
    
    # Setup rotation if not done
    ./scripts/setup-log-rotation.sh
    
  4. Need to clear old logs?

    # PM2 can manage this with rotation, but if needed:
    pm2 flush  # Clear all logs (be careful!)