Deployment Guide
This guide covers the essential steps for deploying Obed to a production environment.
Background Processes
Obed can be configured to run entirely via scheduled tasks (Cron), which is ideal for environments like Dokku where spinning up a dedicated worker container might be resource-heavy.
ONE-SHOT Cron Configuration (Recommended for Dokku)
Instead of running a continuously active worker, you can run two periodic commands.
1. Process Pending Notifications (Hourly)
This wakes up "future" notifications (like reminders) and puts them into the queue.
- Command:
python manage.py process_notifications - Frequency: Hourly (e.g., at minute 0)
2. Execute Tasks (Every 30 mins)
This command processes the queued items (sends the emails/SMS). Using --batch tells it to process all waiting tasks and then exit.
- Command:
python manage.py db_worker --batch --backend notifications --queue notifications --max-tasks 15 - Frequency: Every 30 minutes.
3. Maintenance & Reports
- Session Cleanup:
python manage.py clearsessions(Daily) - Database Cleanup:
python manage.py prune_db_task_results --days 7(Weekly, Sat 05:30) - Failure Report:
python manage.py send_notification_failures(Weekly, Sat 00:30)
Dokku app.json Example:
{
"cron": [
{
"command": "python manage.py clearsessions",
"schedule": "@daily"
},
{
"command": "python manage.py process_notifications",
"schedule": "0 * * * *"
},
{
"command": "python manage.py db_worker --batch --backend notifications --queue notifications --max-tasks 15",
"schedule": "*/30 * * * *"
},
{
"command": "python manage.py prune_db_task_results --days 7",
"schedule": "30 5 * * 6"
},
{
"command": "python manage.py send_notification_failures",
"schedule": "30 0 * * 6"
}
]
}Alternative: Dedicated Worker
If you prefer a traditional worker setup (e.g., for instant email delivery):
- Worker: Run
python manage.py db_worker --backend notificationscontinuously. - Cron: You STILL need the
process_notificationscron job to wake up future reminders.
Deployment Checklist
[ ] Environment Variables: Configure all variables listed in Environment Variables. [ ] Static Files: Run python manage.py collectstatic. [ ] Migrations: Run python manage.py migrate. [ ] Worker: Start the db_worker process. [ ] Cron: Configure the process_notifications cron job. [ ] HTTPS: Ensure SSL requires are met (Turnstile and other security features depend on it).