mcfedr/resque-queue-driver-bundle

此包已被弃用且不再维护。作者建议使用 mcfedr/queue-manager-bundle 包。

用于运行带有 Redis 后端的 symfony 后台任务的包

安装数: 2,817

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 3

公开问题: 0

类型:symfony-bundle

3.5.0 2018-02-24 08:10 UTC

This package is auto-updated.

Last update: 2022-02-01 12:55:22 UTC


README

Queue Manager Bundle 的一个驱动程序,使用 resque

Latest Stable Version License Build Status

使用方法

PHP Resque 将两个命令安装到您的 bin 文件夹中。通常,您只需要运行一个 resque-scheduler 实例和多个 resque 实例。

QUEUE=default APP_INCLUDE=var/bootstrap.php.cache REDIS_BACKEND=127.0.0.1:6379 ./vendor/bin/resque
PREFIX="my_app:" REDIS_BACKEND=127.0.0.1:6379 ./vendor/bin/resque-scheduler
  • VVERBOSE=1 添加到环境变量中可以获得更多日志记录。

在微服务架构中,可以将作业的队列(主)和执行(从)解耦。为此,如果它们与主服务器不同,可能需要为工作器设置特定的 kernel_options

  • 使用完全限定的类名添加 KERNEL_CLASS 以覆盖 kernel.root_dir 选项。如果您的内核不在根命名空间中(例如在 symfony flex 应用程序中),这是指定内核类名称的唯一方法。
  • 添加 SYMFONY_ENVAPP_ENV 以覆盖 kernel.environment 选项。
  • 添加 SYMFONY_DEBUGAPP_DEBUG 以覆盖 kernel.debug 选项。

安装

Composer

composer require mcfedr/resque-queue-driver-bundle

AppKernel

将包包含到您的 AppKernel 中

public function registerBundles()
{
    $bundles = [
        ...
        new Mcfedr\QueueManagerBundle\McfedrQueueManagerBundle(),
        new Mcfedr\ResqueQueueDriverBundle\McfedrResqueQueueDriverBundle(),

配置

安装此包后,您可以将队列管理器配置设置为类似以下内容

mcfedr_queue_manager:
    managers:
        default:
            driver: resque
            options:
                host: 127.0.0.1
                port: 11300
                default_queue: default
                track_status: false

这将为名为 "mcfedr_queue_manager.default"QueueManager 服务创建

  • hostport - Redis 服务器位置
  • default_queue - 要使用的默认队列名称
  • track_status - 设置为 true 以在 Redis 中存储额外的作业跟踪数据。对调试很有用

QueueManager::put 的选项

  • queue - 一个包含队列名称的 string
  • time - 表示安排此作业的 \DateTime 对象
  • delay - 从现在开始安排此作业的秒数
  • track_status - 设置为 true 以在 Redis 中存储额外的作业跟踪数据。对调试很有用