Overview
Baker uses the cronbake library to manage scheduled actions, allowing you to automate device operations like reboots, cleanups, health checks, and custom scripts on flexible time schedules.Configuration
Docker Compose
Environment variables
| Variable | Description | Default |
|---|---|---|
PORT | Service port | 3000 |
STREAM_API_URL | MediaMTX API endpoint | Required |
POCKETBASE_URL | PocketBase connection URL | Required |
JOYSTICK_API_URL | Joystick service URL | Required |
Dependencies
Baker uses the following key dependencies:Features
Cron-based scheduling
Schedule actions using standard cron expressions:- Minute precision - Run tasks at specific minutes
- Hourly schedules - Execute tasks every hour or at specific hours
- Daily schedules - Run tasks at specific times each day
- Weekly schedules - Execute on specific days of the week
- Monthly schedules - Run on specific dates
Action execution
Baker executes actions via the Joystick API:- Device actions - Run any configured device action
- Parameter support - Pass parameters to actions
- Error handling - Log failures and retry logic
- Execution history - Track scheduled action runs
Cron expression format
Baker uses standard cron format:Common examples
Use cases
Daily device reboot
Reboot devices every day at 3 AM:Periodic cleanup
Clean up old files every 6 hours:Weekly health check
Run comprehensive health check every Sunday:Hourly status update
Update device status every hour:Integration with Joystick
Baker executes actions by making API calls to Joystick:PocketBase integration
Baker is typically called by PocketBase hooks when specific events occur:Logging and monitoring
Baker provides logging for scheduled executions:Error handling
Baker handles various error scenarios:- Device offline - Logs error, may retry based on configuration
- Action not found - Logs error, disables schedule
- Invalid parameters - Logs validation error
- Network errors - Retries with backoff
API endpoints
While Baker primarily works via PocketBase integration, it exposes endpoints for management:Sync schedules
List active schedules
Trigger schedule manually
Health check
Best practices
Avoid overlapping executions
Ensure actions complete before the next scheduled run:Use appropriate intervals
Don’t over-schedule resource-intensive tasks:Consider timezone
Baker uses the system timezone. Document your schedules:Enable/disable schedules
Use the enabled flag for temporary suspension:Troubleshooting
Schedule not executing
- Verify cron expression is valid
- Check
enabledflag is true - Review Baker service logs
- Ensure Joystick API is accessible
Actions failing
- Verify device is online
- Check action exists in PocketBase
- Validate action parameters
- Review Joystick service logs
Performance issues
- Reduce schedule frequency
- Stagger multiple device schedules
- Monitor resource usage
- Optimize action execution time