mirror of
https://github.com/thecyberlearn/quantum-ai-v3.git
synced 2026-08-18 07:52:57 +00:00
3.0 KiB
3.0 KiB
🔐 Railway Environment Variables Checklist
Critical Variables for Health Check Success
✅ Required Variables (Must Set These)
# Django Core (REQUIRED)
SECRET_KEY=your-50-character-secret-key
DEBUG=False
ALLOWED_HOSTS=your-project.railway.app,quantumtaskai.com
# Database (AUTO-SET by Railway PostgreSQL service)
# DATABASE_URL=postgresql://... (Railway sets this automatically)
⚠️ Optional Variables (Set if Using Features)
# Email Configuration (for contact form, password reset)
EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-gmail-app-password
DEFAULT_FROM_EMAIL=Quantum Tasks AI <noreply@quantumtaskai.com>
# Stripe Payment (for wallet functionality)
STRIPE_SECRET_KEY=sk_live_your_stripe_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
# N8N Webhooks (for AI agents that use webhooks)
N8N_WEBHOOK_DATA_ANALYZER=https://your-n8n-url/webhook/data-analyzer
N8N_WEBHOOK_FIVE_WHYS=https://your-n8n-url/webhook/five-whys
N8N_WEBHOOK_JOB_POSTING=https://your-n8n-url/webhook/job-posting
N8N_WEBHOOK_SOCIAL_ADS=https://your-n8n-url/webhook/social-ads
# OpenWeather API (for weather agent)
OPENWEATHER_API_KEY=your_openweather_key
🚨 Health Check Failure Troubleshooting
Most Common Issues:
-
Missing SECRET_KEY
Error: "The SECRET_KEY setting must not be empty" Solution: Set SECRET_KEY in Railway variables -
Database Not Ready
Error: "connection to server failed" Solution: Wait 30-60 seconds, Railway PostgreSQL is starting -
Wrong ALLOWED_HOSTS
Error: "DisallowedHost at /health/" Solution: Add Railway domain to ALLOWED_HOSTS
🔧 Quick Fixes
Generate SECRET_KEY
# Run locally
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
Minimal Working Configuration
# These 3 variables will make health check pass:
SECRET_KEY=your-generated-secret-key-here
DEBUG=False
ALLOWED_HOSTS=your-project.railway.app
Test Health Check Locally
# Set minimal env vars and test
export SECRET_KEY="your-secret-key"
export DEBUG=False
export ALLOWED_HOSTS="localhost,127.0.0.1"
python manage.py runserver
curl http://localhost:8000/health/
📊 Expected Health Check Response
{
"status": "healthy",
"timestamp": 1690123456,
"version": "1.0",
"checks": {
"database": {
"status": "healthy",
"response_time_ms": 12.3,
"attempt": 1
},
"agents": {
"status": "healthy",
"active_count": 6
},
"application": {
"status": "healthy",
"django_ready": true
}
},
"response_time_ms": 45.2
}
🎯 Deployment Steps
- Set minimum required variables in Railway
- Deploy with updated railway.json (60s timeout)
- Check Railway logs for errors
- Test health endpoint:
curl https://your-project.railway.app/health/ - Add optional variables as needed for full functionality
Health check should pass within 60 seconds with just the 3 critical variables!