Production-ready FastAPI application with Celery task processing. Includes health checks, task triggers, worker monitoring, and Railway deployment support.
-
Add Redis to your Railway project
New → Database → Add Redis -
Deploy this service
New → GitHub Repo → Select this repository -
Set environment variables
REDIS_URL = ${{Redis.REDIS_URL}} -
Deploy! Railway will automatically detect the Dockerfile
For full functionality, deploy all three templates:
- This FastAPI template (API)
- Celery Worker template (processes tasks)
- Celery Beat template (schedules tasks)
All should share the same Redis instance via ${{Redis.REDIS_URL}}.
Edit app/main.py:
@app.post("/your-endpoint")
async def your_endpoint(data: YourModel):
# Your logic here
task_id = trigger_your_task(data)
return {"task_id": task_id}- Define task signature in
app/tasks.py:
your_task = celery_app.signature("your_task")
def trigger_your_task(data):
result = your_task.delay(data)
return result.id- Implement the actual task in the worker template
Edit app/config.py to add more settings:
class Settings(BaseSettings):
# Add your settings here
database_url: str = ""
api_key: str = ""# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# With coverage
pytest --cov=app tests/Swagger UI: http://localhost:8000/docs | ReDoc: http://localhost:8000/redoc
Email sending, image processing, data exports, webhook handling, notifications.
# Check Redis is running
docker ps | grep redis
# Test connection
redis-cli -u $REDIS_URL pingDeploy the worker template and ensure it shares the same REDIS_URL
- Ensure worker service is running
- Check worker logs for errors
- Verify Redis connectivity
MIT