Scheduler
class Scheduler (View source)
Class Scheduler
Simplified scheduler that provides four main methods:
- command(): Run Bow console commands
- task(): Run QueueTask classes
- exec(): Run bash/shell commands
- call(): Run closures/callbacks
Methods
Scheduler constructor
Get the Scheduler instance
Enable or disable logging
Get all registered events
Log a message
Start the scheduler loop (for CLI daemon mode)
Sleep until the next minute boundary
Reset the singleton instance (mainly for testing)
Magic method for static calls
Details
void
__construct()
Scheduler constructor
static Scheduler
getInstance()
Get the Scheduler instance
Scheduler
setLogger(callable $logger)
Set a custom logger callback
Scheduler
enableLogging(bool $enabled = true)
Enable or disable logging
Schedule
command(string $command, array $parameters = [])
Schedule a Bow console command
Schedule
exec(string $command, array $parameters = [])
Schedule a shell/bash command
Schedule
call(callable $callback, array $parameters = [])
Schedule a callback/closure for execution
array
getEvents()
Get all registered events
array
getDueEvents(DateTime|null $currentTime = null)
Get all due events
array
run(DateTime|null $currentTime = null)
Run all due events
protected array
runEvent(ScheduledEvent $event)
Run a single event
protected bool
acquireLock(ScheduledEvent $event)
Acquire a lock for overlap prevention
protected void
releaseLock(ScheduledEvent $event)
Release a lock for an event
protected void
log(string $message)
Log a message
Scheduler
clear()
Clear all registered events
void
start(int $sleepSeconds = 60)
Start the scheduler loop (for CLI daemon mode)
protected void
sleepUntilNextMinute(int $maxSleep = 60)
Sleep until the next minute boundary
static void
reset()
Reset the singleton instance (mainly for testing)
static mixed
__callStatic(string $name, array $arguments)
Magic method for static calls