feat: Enhance logging and error handling for job streaming and photo uploads
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

- 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.
This commit is contained in:
tanyar09
2026-02-04 19:30:05 +00:00
parent 46dffc6ade
commit 7a981b069a
16 changed files with 648 additions and 89 deletions
+115
View File
@@ -0,0 +1,115 @@
# Quick Log Reference
When something fails, use these commands to quickly check logs.
## 🚀 Quick Commands
### Check All Services for Errors
```bash
./scripts/check-logs.sh
```
Shows PM2 status and recent errors from all services.
### Follow Errors in Real-Time
```bash
./scripts/tail-errors.sh
```
Watches all error logs live (press Ctrl+C to exit).
### View Recent Errors (Last 10 minutes)
```bash
./scripts/view-recent-errors.sh
```
### View Errors from Last 30 minutes
```bash
./scripts/view-recent-errors.sh 30
```
## 📋 PM2 Commands
```bash
# 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
```bash
# 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:
```bash
./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?**
```bash
./scripts/check-logs.sh
pm2 logs punimtag-worker --err --lines 100
```
2. **API not responding?**
```bash
pm2 logs punimtag-api --err
pm2 status
```
3. **Large log files?**
```bash
# 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?**
```bash
# PM2 can manage this with rotation, but if needed:
pm2 flush # Clear all logs (be careful!)
```