|
| 1 | +# Debugging Profile Cache Cleaner |
| 2 | + |
| 3 | +## How to Verify It's Running |
| 4 | + |
| 5 | +### 1. Check if the process is running inside the container |
| 6 | + |
| 7 | +SSH to your server and run: |
| 8 | + |
| 9 | +```bash |
| 10 | +docker exec gitranks-ui ps aux | grep profile-cache-cleaner |
| 11 | +``` |
| 12 | + |
| 13 | +You should see the script process running. |
| 14 | + |
| 15 | +### 2. View Docker Logs |
| 16 | + |
| 17 | +The script logs to stdout/stderr, which Docker captures. View logs with: |
| 18 | + |
| 19 | +```bash |
| 20 | +# View all logs |
| 21 | +docker logs gitranks-ui |
| 22 | + |
| 23 | +# Follow logs in real-time |
| 24 | +docker logs -f gitranks-ui |
| 25 | + |
| 26 | +# View only the last 100 lines |
| 27 | +docker logs --tail 100 gitranks-ui |
| 28 | + |
| 29 | +# Filter logs for cache cleaner messages |
| 30 | +docker logs gitranks-ui 2>&1 | grep "profile-cache-cleaner" |
| 31 | +``` |
| 32 | + |
| 33 | +### 3. Verify It Runs Every 10 Minutes |
| 34 | + |
| 35 | +The script logs every time it runs (every 600 seconds). Check timestamps: |
| 36 | + |
| 37 | +```bash |
| 38 | +docker logs gitranks-ui 2>&1 | grep "profile-cache-cleaner" | tail -20 |
| 39 | +``` |
| 40 | + |
| 41 | +You should see log entries approximately every 10 minutes with timestamps like: |
| 42 | +``` |
| 43 | +Mon Jan 20 10:00:00 UTC 2025 [profile-cache-cleaner] Found 15000 profile dirs |
| 44 | +Mon Jan 20 10:10:00 UTC 2025 [profile-cache-cleaner] Found 15000 profile dirs |
| 45 | +Mon Jan 20 10:20:00 UTC 2025 [profile-cache-cleaner] Found 15000 profile dirs |
| 46 | +``` |
| 47 | + |
| 48 | +### 4. Check Script Execution Directly |
| 49 | + |
| 50 | +Execute the script manually inside the container to test: |
| 51 | + |
| 52 | +```bash |
| 53 | +docker exec gitranks-ui /app/lib/shell/profile-cache-cleaner.sh |
| 54 | +``` |
| 55 | + |
| 56 | +(Note: This will run in foreground - press Ctrl+C to stop) |
| 57 | + |
| 58 | +### 5. Verify the Script File Exists and is Executable |
| 59 | + |
| 60 | +```bash |
| 61 | +docker exec gitranks-ui ls -la /app/lib/shell/profile-cache-cleaner.sh |
| 62 | +docker exec gitranks-ui test -x /app/lib/shell/profile-cache-cleaner.sh && echo "Executable" || echo "Not executable" |
| 63 | +``` |
| 64 | + |
| 65 | +### 6. Check if Profile Directory Exists |
| 66 | + |
| 67 | +```bash |
| 68 | +docker exec gitranks-ui ls -la /app/.next/server/app/profile |
| 69 | +docker exec gitranks-ui ls -d /app/.next/server/app/profile/*/ 2>/dev/null | wc -l |
| 70 | +``` |
| 71 | + |
| 72 | +## Expected Log Output |
| 73 | + |
| 74 | +When working correctly, you should see logs like: |
| 75 | + |
| 76 | +``` |
| 77 | +Starting profile cache cleaner. Dir: /app/.next/server/app/profile, max dirs: 30000, interval: 600s |
| 78 | +Mon Jan 20 10:00:00 UTC 2025 [profile-cache-cleaner] Found 15000 profile dirs |
| 79 | +Mon Jan 20 10:10:00 UTC 2025 [profile-cache-cleaner] Found 15200 profile dirs |
| 80 | +Mon Jan 20 10:20:00 UTC 2025 [profile-cache-cleaner] Found 15100 profile dirs |
| 81 | +``` |
| 82 | + |
| 83 | +If the directory doesn't exist yet: |
| 84 | +``` |
| 85 | +Mon Jan 20 10:00:00 UTC 2025 [profile-cache-cleaner] Directory /app/.next/server/app/profile does not exist |
| 86 | +``` |
| 87 | + |
| 88 | +If cleanup is needed: |
| 89 | +``` |
| 90 | +Mon Jan 20 10:00:00 UTC 2025 [profile-cache-cleaner] Found 35000 profile dirs |
| 91 | +Mon Jan 20 10:00:00 UTC 2025 [profile-cache-cleaner] Need to remove 5000 oldest dirs |
| 92 | + removing /app/.next/server/app/profile/abc123/ |
| 93 | + removing /app/.next/server/app/profile/def456/ |
| 94 | + ... |
| 95 | +``` |
| 96 | + |
| 97 | +## Troubleshooting |
| 98 | + |
| 99 | +### Script not running? |
| 100 | +1. Check container logs: `docker logs gitranks-ui` |
| 101 | +2. Check if process exists: `docker exec gitranks-ui ps aux | grep profile` |
| 102 | +3. Verify script permissions: `docker exec gitranks-ui ls -la /app/lib/shell/profile-cache-cleaner.sh` |
| 103 | + |
| 104 | +### No logs appearing? |
| 105 | +1. The script might be failing silently - check with: `docker exec gitranks-ui sh -c "/app/lib/shell/profile-cache-cleaner.sh"` (run manually) |
| 106 | +2. Check if the script has proper shebang: `docker exec gitranks-ui head -1 /app/lib/shell/profile-cache-cleaner.sh` |
| 107 | + |
| 108 | +### Script runs but no cleanup happens? |
| 109 | +1. Check if directory exists: `docker exec gitranks-ui test -d /app/.next/server/app/profile && echo "Exists" || echo "Missing"` |
| 110 | +2. Check current count: `docker exec gitranks-ui ls -d /app/.next/server/app/profile/*/ 2>/dev/null | wc -l` |
| 111 | +3. Verify MAX_DIRS threshold (currently 30000) - if count is below this, no cleanup will occur |
| 112 | + |
0 commit comments