Queues & Scheduled Tasks
ProcessWire Console ships a database-backed queue engine (Totoglu\Console\Queue\Queue / QueueManager) and a cron scheduler (Totoglu\Console\Scheduling\Task / Event) that automatically discovers jobs and tasks inside site/queue/, site/schedule/, and installed modules.
Queue Commands (6)
Section titled “Queue Commands (6)”| Command | Arguments & Options | Purpose |
|---|---|---|
queue:table |
--json |
Creates the queue_jobs and failed_jobs database tables idempotently. |
make:queue |
<name>, --module, --json |
Scaffolds a new *Queue.php job handler class in site/queue/ (or a module’s queue/ folder). |
queue:work |
--queue, --sleep, --tries, --memory, --once, --json |
Processes pending jobs continuously (or processes a single job with --once). |
queue:failed |
--limit, --json |
Lists failed jobs stored in failed_jobs along with error details. |
queue:retry |
<id>, --json |
Moves a failed job (or all) back onto the pending queue for reprocessing. |
queue:clear |
--dry-run, --force, --json |
Purges all rows from the failed_jobs table. |
Example Queue Handler & Dispatch
Section titled “Example Queue Handler & Dispatch”<?php
declare(strict_types=1);
namespace ProcessWire;
use Totoglu\Console\Queue\Queue;
final class SendCharterQuoteQueue extends Queue{ public function handle(array $payload): void { $bookingId = (string) ($payload['booking_id'] ?? ''); wire()->log->save('charter-queue', "Dispatched quote email for booking {$bookingId}"); }}Production Queue Worker (Supervisor)
Section titled “Production Queue Worker (Supervisor)”[program:pw-queue]command=/usr/bin/php /var/www/aegeanvoyages.example/vendor/bin/wire queue:work --tries=3 --sleep=3 --memory=256autostart=trueautorestart=trueuser=www-dataredirect_stderr=truestdout_logfile=/var/log/pw-queue.logScheduling Commands (2)
Section titled “Scheduling Commands (2)”| Command | Arguments & Options | Purpose |
|---|---|---|
make:task |
<name>, --module, --json |
Scaffolds a new *Task.php scheduled task class in site/schedule/ (or a module’s schedule/ folder). |
schedule:run |
--json |
Evaluates every discovered Task class and runs all due cron events for the current minute. |
Example Scheduled Task
Section titled “Example Scheduled Task”<?php
declare(strict_types=1);
namespace ProcessWire;
use Totoglu\Console\Scheduling\Event;use Totoglu\Console\Scheduling\Task;
final class PruneTempQuotesTask extends Task{ public function schedule(Event $event): void { $event->dailyAt('03:15'); }
public function handle(): void { wire()->log->save('schedule', 'Pruned expired temporary quotes.'); }}Single System Crontab Entry
Section titled “Single System Crontab Entry”Add one minute-level cron entry on your server to power every project and module scheduled task (AccountPruneTask, ExpireCharterHoldsTask, SyncExchangeRatesTask, MediaMaintenanceTask, PruneAiUsageLogsTask, and your own site/schedule/*Task.php classes):
* * * * * cd /var/www/aegeanvoyages.example && /usr/bin/php vendor/bin/wire schedule:run >> /var/log/pw-schedule.log 2>&1