webupdate
Some checks are pending
CI / build (push) Waiting to run

This commit is contained in:
Local Server
2026-01-23 23:54:24 -06:00
parent 1b2502c38d
commit 44c7ebde6f
5 changed files with 290 additions and 11 deletions

164
docs/SITE_RECOVERY_GUIDE.md Normal file
View File

@@ -0,0 +1,164 @@
# SkyArtShop Site Recovery Guide
## Issues Fixed (January 23, 2026)
### Root Causes Identified
1. **Rate Limiter IPv6 Error** - Backend was crashing on startup
2. **Database Permission Denied** - User `pts` couldn't access tables
3. **Database Connection Pool Errors** - Connections being terminated
---
## Fixes Applied
### 1. Fixed Rate Limiter (rateLimiter.js)
**Problem:** Custom keyGenerator was not IPv6-compliant, causing backend crashes
**Solution:** Removed custom keyGenerator to use express-rate-limit defaults
```javascript
// REMOVED the custom keyGenerator that was causing IPv6 validation errors
// Now using default IP handling which is IPv6-safe
```
### 2. Fixed Database Permissions
**Problem:** User `pts` had no permissions on database tables
**Solution:**
```bash
sudo -u postgres psql -d skyartshop -f backend/scripts/fix-db-permissions.sql
```
This grants:
- SELECT, INSERT, UPDATE, DELETE on all tables
- USAGE, SELECT on all sequences
- EXECUTE on all functions
- Default privileges for future objects
### 3. Database Connection Stability
**Problem:** Database pool errors causing disconnections
**Solution:** Restarted backend after permission fixes
```bash
pm2 restart skyartshop
```
---
## Monitoring & Prevention
### Health Monitor Script
Run anytime to check system status:
```bash
/media/pts/Website/SkyArtShop/backend/scripts/health-monitor.sh
```
Checks:
- PM2 process status
- Backend port availability
- Database connectivity
- Database permissions
- HTTP/HTTPS responses
- CSS asset loading
- Recent error counts
### Quick Troubleshooting Commands
#### Check if site is accessible
```bash
curl -I https://skyartshop.dynns.com
```
#### Check backend status
```bash
pm2 status
pm2 logs skyartshop --lines 20
```
#### Check database connection
```bash
psql -U pts -d skyartshop -c "SELECT COUNT(*) FROM pages WHERE isactive = true;"
```
#### Restart backend
```bash
pm2 restart skyartshop
```
#### Fix database permissions
```bash
sudo -u postgres psql -d skyartshop -f /media/pts/Website/SkyArtShop/backend/scripts/fix-db-permissions.sql
```
---
## Prevention Measures
### 1. Always check logs after restart
```bash
pm2 logs skyartshop --lines 50 --nostream
```
### 2. Run health monitor before and after changes
```bash
./backend/scripts/health-monitor.sh
```
### 3. Keep database permissions script ready
Location: `/media/pts/Website/SkyArtShop/backend/scripts/fix-db-permissions.sql`
### 4. Monitor for these error patterns
- `ERR_ERL_KEY_GEN_IPV6` - Rate limiter issues
- `permission denied` - Database permission issues
- `terminating connection` - Database pool issues
- `Route not found` - Routing configuration issues
---
## Symptoms & Solutions
| Symptom | Likely Cause | Solution |
|---------|--------------|----------|
| Pink background, no content | Backend crash/not running | Check PM2 logs, restart backend |
| 502 Bad Gateway | Backend not listening | Restart PM2: `pm2 restart skyartshop` |
| Database errors in logs | Permission issues | Run fix-db-permissions.sql |
| Backend crashes on startup | Code error (check error.log) | Review recent code changes, check logs |
| CSS not loading | Nginx/static file issue | Check nginx config, restart nginx |
---
## Current Status (2026-01-23 22:52)
✅ All systems operational
✅ Backend running (PM2)
✅ Database connected
✅ Permissions fixed
✅ Site accessible at <https://skyartshop.dynns.com>
✅ CSS and assets loading correctly
---
## Contact & Support
- Backend logs: `/media/pts/Website/SkyArtShop/backend/logs/`
- Health monitor: `./backend/scripts/health-monitor.sh`
- DB permissions: `./backend/scripts/fix-db-permissions.sql`