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
feat(core): add run-on-startup option for jobs (#436)
## Summary
Add optional `run-on-startup` parameter that executes jobs immediately
when the scheduler starts, before regular cron scheduling begins.
- Add `RunOnStartup` field to `BareJob` struct (applies to all job
types: exec, run, local, service-run, compose)
- Add `ShouldRunOnStartup()` method to `Job` interface
- Add `runStartupJobs()` method to Scheduler that runs startup jobs in
goroutines for non-blocking execution
- Include `RunOnStartup` in job hash for change detection
### Configuration Example
```ini
[job-exec "backup"]
schedule = @daily
container = my-container
command = /backup.sh
run-on-startup = true
```
### Design Decisions
1. **Non-blocking**: Startup jobs run in goroutines to prevent blocking
other job registrations and scheduler start
2. **All job types**: The option is in `BareJob`, so it works for exec,
run, local, service-run, and compose jobs
3. **Default false**: Existing configurations are unaffected (backward
compatible)
## Test Plan
- [x] Verify job with `run-on-startup=true` executes on scheduler start
- [x] Verify job with `run-on-startup=false` does NOT run on startup
- [x] Verify multiple startup jobs run concurrently (non-blocking)
- [x] Verify `Start()` returns immediately (non-blocking verification)
- [x] Verify config parsing works for all job types
- [x] Verify triggered-only jobs (`@triggered`) with
`run-on-startup=true` work correctly
- [x] All existing tests pass
- [x] Lint passes
Closes#347
0 commit comments