schedule-bundle
schedule-bundle copied to clipboard
Task triggers (ie deploy)
Ability to add tasks to a "trigger group" like deploy
:
class AppScheduleBuilder implements ScheduleBuilder
{
public function buildSchedule(Schedule $schedule): void
{
$schedule->addCommand('app:warm-cache')
->trigger('deploy')
->unscheduled() // disables task from bring run except when "triggered"
;
$schedule->addCommand('app:health-check')
->hourly() // also runs hourly
->trigger('deploy', priority: 10) // would run before the above task
;
// ...
}
}
Run the trigger (ie in a post deployment script):
bin/console schedule:trigger deploy
Combined with #58:
#[Schedule('@daily', trigger: 'deploy')]
class MyService
{
public function __invoke()
{
// ...
}
}
#[Schedule('@weekly', trigger: 'deploy')]
class MyCommand extends Command
{
public function execute(InputInterface $input, OutputInterface $output): int
{
// ...
}
}
A dedicated Trigger
attribute could be added to make unscheduled invokable service/console command tasks:
#[Trigger('deploy')]
class MyService
{
public function __invoke()
{
// ...
}
}
#[Trigger('deploy')]
class MyCommand extends Command
{
public function execute(InputInterface $input, OutputInterface $output): int
{
// ...
}
}