Search by

mleczakm / swoole-bundle-scheduler

Run Symfony Scheduler inside the Swoole HTTP server on a Swoole\Timer::tick() loop instead of a blocking messenger:consume worker.

Maintainers

Package info

github.com/mleczakm/swoole-bundle-scheduler

Type:symfony-bundle

pkg:composer/mleczakm/swoole-bundle-scheduler

Transparency log

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-09-03 09:53 UTC

This package is auto-updated.

Last update: 2026-09-03 09:56:07 UTC


README

Run Symfony Scheduler inside the Swoole HTTP server, on a Swoole\Timer::tick() loop - no separate messenger:consume scheduler_* worker process to run, supervise, restart, or pay memory for.

A companion package to swoole-bundle/swoole-bundle.

Install

composer require mleczakm/swoole-bundle-scheduler
// config/bundles.php
SwooleBundle\Scheduler\SwooleBundleSchedulerBundle::class => ['all' => true],
# config/packages/swoole_bundle_scheduler.yaml
swoole_bundle_scheduler:
    enabled: true
    interval: 60

Define a schedule the normal Symfony way (#[AsSchedule] + ScheduleProviderInterface) and it is polled automatically. Restart the Swoole server to pick it up.

What you get

  • Polls every #[AsSchedule] provider off the Swoole event loop, dispatching due messages through the message bus with the same PreRunEvent / PostRunEvent / FailureEvent as Symfony's own worker.
  • A failed tick is logged and retried next interval - it never crashes the server.
  • Overlapping ticks are skipped, not queued.
  • Each tick resets the pooled stateful services it touches, via the swoole-bundle's own coroutine boundary machinery.

Opt-in production hardening

All disabled by default; enable per app when you hit the failure mode:

Option Defends against
lock The tick firing in a second OS process (Swoole manager during reload) and double-dispatching
watchdog A hung Scheduler::run() wedging the scheduler forever behind a never-freed semaphore
heartbeat + health_check A wedged scheduler staying invisible while /health keeps passing
pre_run / after_tick App-specific readiness checks / state resets around each tick

Docs

Requirements

  • PHP >= 8.3, ext-swoole
  • swoole-bundle/swoole-bundle ^0.32 with coroutines enabled
  • symfony/scheduler + symfony/messenger
  • symfony/lock (only for the lock option)
  • macpaw/symfony-health-check-bundle (only for the health_check option)

License

MIT