You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sudo nano /etc/systemd/system/fastapi.service
# Change -w 4 to desired number
sudo systemctl daemon-reload
sudo systemctl restart fastapi
View System Resources
# Memory
free -h
# Disk
df -h
# CPU
top
htop # if installed# Running processes
ps aux | grep gunicorn
Troubleshooting
Service Won't Start
# Check logs for errors
sudo journalctl -u fastapi -n 100 --no-pager
# Test manuallycd /home/ubuntu/cardlabsv3.0
source venv/bin/activate
python main.py
# Or test with gunicorn
gunicorn -w 1 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:8000
Database Connection Issues
# Check if PostgreSQL is running
sudo systemctl status postgresql
# Test connection
sudo -u postgres psql -c "SELECT 1"# Check .env file
cat /home/ubuntu/cardlabsv3.0/.env
502 Bad Gateway
# Check if app is running
sudo systemctl status fastapi
# Check nginx is running
sudo systemctl status nginx
# Test app directly
curl http://localhost:8000
# Check nginx error logs
sudo tail -f /var/log/nginx/error.log
High Memory Usage
# Check processes
ps aux --sort=-%mem | head -10
# Reduce workers in systemd service
sudo nano /etc/systemd/system/fastapi.service
# Change -w 4 to -w 2
sudo systemctl daemon-reload
sudo systemctl restart fastapi
Monitoring
Check if App is Responding
# Local test
curl http://localhost:8000
# Full test with headers
curl -I https://your-domain.com
# Response time
curl -w "@-" -o /dev/null -s https://your-domain.com <<'EOF' time_total: %{time_total}s\nEOF