# Operare Website DiDi ## Comenzi uzuale ### Status ```bash docker compose ps docker stats --no-stream didi-website ``` ### Restart ```bash docker compose restart website # sau cu rebuild docker compose up -d --build website ``` ### Log-uri ```bash # Live log docker compose logs -f website # Doar erori docker compose logs website 2>&1 | grep -E "error|ERROR|FAIL" # Ultimele 100 linii docker compose logs --tail 100 website ``` ### Restart dupa schimbare cod (rebuild) ```bash cd ~/website docker compose up -d --build website # Verifica docker logs --tail 10 didi-website ``` ## Update env vars ### Schimbare cheie Stripe / SendGrid / etc. 1. Editeaza `.env.production` 2. Rebuild (env vars sunt baked in la build): ```bash docker compose up -d --build website ``` Pentru variabilele `NEXT_PUBLIC_*` (folosite in client), trebuie REBUILD. Pentru variabile server-side, doar restart e suficient. ## Monitorizare ### Health check ```bash curl -s -o /dev/null -w "%{http_code}\n" http://localhost:3000 curl -s http://localhost:3000/api/auth/session | python3 -m json.tool ``` ### Performance ```bash # Time First Byte curl -s -o /dev/null -w "TTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n" http://localhost:3000 # Lighthouse (necesita Node/Chrome pe host - sau via Docker) docker run --rm --network didi-network \ -v $(pwd):/out \ femtopixel/google-lighthouse \ http://didi-website:3000 \ --output html --output-path /out/lighthouse-report.html ``` ## Troubleshooting ### Site nu raspunde ```bash # 1. Container status docker compose ps # 2. Log-uri docker compose logs --tail 50 website # 3. Test conectivitate la dependinte (din container) docker exec didi-website wget -qO- http://didi-erpnext:8080 | head -1 docker exec didi-website wget -qO- https:///auth/realms/didi-clients | head -c 100 ``` ### Auth nu functioneaza ```bash # Verifica OIDC discovery docker exec didi-website wget -qO- https:///auth/realms/didi-clients/.well-known/openid-configuration | python3 -m json.tool # Verifica cookies Auth.js # Browser DevTools > Application > Cookies > # Trebuie sa existe: authjs.csrf-token, authjs.session-token (dupa login) ``` ### Stripe checkout nu mai redirecteaza dupa plata Verifica `NEXT_PUBLIC_SITE_URL` in `.env.production` - trebuie sa fie acelasi host cu cel din browser. ```bash docker exec didi-website env | grep -E "AUTH_URL|NEXT_PUBLIC_SITE" ``` ### Webhook Stripe nu firea Webhook-ul fireaza doar daca Stripe poate ajunge la endpoint-ul tau. In dev local: ```bash # Stripe CLI (instaleaza separat) stripe listen --forward-to http://:3000/api/webhooks/stripe # Test manual cu curl (simuleaza un event) curl -X POST http://:3000/api/webhooks/stripe \ -H "Content-Type: application/json" \ -d '{"type":"checkout.session.completed","data":{"object":{...}}}' ``` In productie verifica Stripe Dashboard > Webhooks > [endpoint] > "Activity feed" pentru status delivery. ### PDF rapoarte goale / corupte Generarea PDF se face cu jsPDF in browser (pentru rapoarte analize) sau wkhtmltopdf in ERPNext (pentru facturi). Pentru facturi - verifica `host_name` in ERPNext: ```bash docker exec didi-erpnext bash -c ' cd /home/frappe/frappe-bench && bench --site didi-erp set-config -g host_name "http://didi-erpnext:8080" ' ``` Pentru rapoarte analize - DevTools > Console pentru erori jsPDF. ### Site nu trage continut din ERPNext CMS ```bash # Test API direct curl -s -H "Authorization: token :" \ "http://localhost:8080/api/resource/Website%20Content?fields=[%22page_slug%22,%22section_key%22]&limit_page_length=5" ``` Daca 401, token-ul e gresit. Daca [], DB-ul nu are inregistrari (re-ruleaza `scripts/setup/04-populate-content.py` din erp_crm). ## Backup Website-ul e stateless - tot ce conteaza e in: - Git repo (codul) - ERPNext DB (datele clientilor + facturile) - Stripe (platile - irretrievable backup) Pentru codul actual: ```bash cd ~ tar czf website-backup-$(date +%Y%m%d).tar.gz \ --exclude='node_modules' \ --exclude='.next' \ website/ ``` ## Performance tuning ### Numar workers Next.js Edit `Dockerfile` (sau env var pentru Next 16): ```dockerfile ENV NEXT_PUBLIC_WORKERS=4 ``` ### Cache HTTP In productie, pune un reverse proxy (nginx/Caddy) cu: - Cache pe static assets (`_next/static/*`, `public/*`): max-age=31536000 immutable - Cache pe pagini SSR cu revalidate (vezi `force-dynamic` / `revalidate`) ### Imagini Public images sunt cache-uite implicit cu max-age=60 in Next 16. Pentru imagini hostate la utilizator (avatar etc.), foloseste `` cu `loader` + CDN. ## SLA | Severitate | Descriere | Raspuns | Rezolvare | |------------|-----------|---------|-----------| | Critica | Site down / login nu functioneaza | 4 ore | 24 ore | | Majora | Functionalitate importanta (checkout, dashboard) | 8 ore | 3 zile | | Minora | UI, cosmetic, edge case | 24 ore | 10 zile | Suport: office@clossers.com, zile lucratoare 09-18.