Skip to content

Latest commit

 

History

History
194 lines (150 loc) · 6.92 KB

File metadata and controls

194 lines (150 loc) · 6.92 KB

Whatflix - Deployment Documentation

Server Location

Production Server: norisor (stonks@norisor.local)

  • OS: Debian 13 (Linux 6.12)
  • Python: 3.13.5
  • IP LAN: 192.168.1.7
  • Path: ~/@dev/whatflix

Access URLs

Type URL
LAN http://norisor.local:8888
LAN (IP) http://192.168.1.7:8888
Public https://*.trycloudflare.com (temporar, se schimba la restart)

Architecture

┌─────────────────────────────────────────────────────────┐
│                      INTERNET                           │
└─────────────────────┬───────────────────────────────────┘
                      │
┌─────────────────────▼───────────────────────────────────┐
│              Cloudflare Tunnel (QUIC)                   │
│         *.trycloudflare.com → localhost:8888            │
└─────────────────────┬───────────────────────────────────┘
                      │
┌─────────────────────▼───────────────────────────────────┐
│                    NORISOR                              │
│  ┌───────────────────────────────────────────────────┐  │
│  │  uvicorn (FastAPI)                                │  │
│  │  Port: 8888                                       │  │
│  │  Path: ~/@dev/whatflix                            │  │
│  │  Venv: .venv/                                     │  │
│  └───────────────────────────────────────────────────┘  │
│                                                         │
│  ┌───────────────────────────────────────────────────┐  │
│  │  cloudflared tunnel                               │  │
│  │  Quick tunnel (no config)                         │  │
│  └───────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────┘

Quick Deploy Commands

SSH to server

ssh stonks@norisor.local

Start Server

cd ~/@dev/whatflix
source .venv/bin/activate
nohup uvicorn app.main:app --host 0.0.0.0 --port 8888 > server.log 2>&1 &

Start Cloudflare Tunnel

# IMPORTANT: --config /dev/null ignora config-ul ERP existent
nohup cloudflared tunnel --config /dev/null --url http://localhost:8888 > ~/cf-whatflix.log 2>&1 &

# Get URL:
grep -o 'https://[^|]*\.trycloudflare.com' ~/cf-whatflix.log | head -1

Full Deploy (one-liner)

ssh stonks@norisor.local "cd ~/@dev/whatflix && source .venv/bin/activate && pkill -f 'uvicorn.*whatflix' ; nohup uvicorn app.main:app --host 0.0.0.0 --port 8888 > server.log 2>&1 &"

Full Deploy + Tunnel (one-liner)

ssh stonks@norisor.local "cd ~/@dev/whatflix && source .venv/bin/activate && pkill -f 'uvicorn.*8888' ; pkill -f 'cloudflared.*8888' ; nohup uvicorn app.main:app --host 0.0.0.0 --port 8888 > server.log 2>&1 & sleep 2 && nohup cloudflared tunnel --config /dev/null --url http://localhost:8888 > ~/cf-whatflix.log 2>&1 &" && sleep 8 && ssh stonks@norisor.local "grep -o 'https://[^|]*\.trycloudflare.com' ~/cf-whatflix.log | head -1"

Stop Commands

Stop Server

ssh stonks@norisor.local "pkill -f 'uvicorn.*8888'"

Stop Tunnel

ssh stonks@norisor.local "pkill -f 'cloudflared.*8888'"

Stop Both

ssh stonks@norisor.local "pkill -f 'uvicorn.*8888' ; pkill -f 'cloudflared.*8888'"

Check Status

Server running?

ssh stonks@norisor.local "ps aux | grep 'uvicorn.*8888' | grep -v grep"

Tunnel running?

ssh stonks@norisor.local "ps aux | grep 'cloudflared.*8888' | grep -v grep"

Server logs

ssh stonks@norisor.local "tail -20 ~/@dev/whatflix/server.log"

Tunnel logs

ssh stonks@norisor.local "tail -20 ~/cf-whatflix.log"

Test local

ssh stonks@norisor.local "curl -s http://localhost:8888/ | head -3"

Sync Code from Local

rsync -avz --exclude='.venv' --exclude='__pycache__' --exclude='*.pyc' --exclude='.git' \
  /home/stonks/@dev/whatflix/ stonks@norisor.local:~/@dev/whatflix/

Initial Setup (done once)

1. Create venv and install dependencies

ssh stonks@norisor.local "cd ~/@dev/whatflix && python3 -m venv .venv && source .venv/bin/activate && pip install fastapi uvicorn httpx pydantic"

2. Verify

ssh stonks@norisor.local "cd ~/@dev/whatflix && source .venv/bin/activate && python -c 'import fastapi; print(fastapi.__version__)'"

Firebase Auth Setup

Pentru login cu Google, adauga domeniul in Firebase Console:

  1. https://console.firebase.google.com
  2. Project: whatflix-18747
  3. Authentication → Settings → Authorized domains
  4. Add:
    • norisor.local
    • *.trycloudflare.com (sau URL-ul specific)

Troubleshooting

Port already in use

ssh stonks@norisor.local "lsof -i :8888"
ssh stonks@norisor.local "pkill -f 'uvicorn.*8888'"

Tunnel returns 404

Cauza: config-ul default cloudflared (pentru ERP) intercepteaza requesturile. Solutie: foloseste --config /dev/null

Cannot connect from LAN

# Check firewall
ssh stonks@norisor.local "sudo ufw status"

# Check server binds to 0.0.0.0
ssh stonks@norisor.local "ss -tlnp | grep 8888"

Dependency issues (Python 3.13)

Nu folosi versiuni pinned vechi. Instaleaza fara versiuni:

pip install fastapi uvicorn httpx pydantic

Important Notes

  1. ⚠️ NU RESTARTA TUNELUL CLOUDFLARE - URL-ul e inregistrat in Firebase pentru OAuth. Daca restartezi tunelul, URL-ul se schimba si auth-ul nu mai merge. Doar uvicorn se poate restarta.

  2. ERP tunnel ruleaza separat pe acelasi server (cloudflared tunnel run erp). Nu-l opri cand faci deploy la whatflix.

  3. Server logs se suprascriu la restart. Pentru persistenta, foloseste >> in loc de >.

  4. API Key Gemini e in .env (loaded via python-dotenv). Nu uita sa sincronizezi .env pe norisor.


Last updated: 2026-01-27 Deployed by: Claude Code