shonm/php-resque-pool
Composer 安装命令:
composer require shonm/php-resque-pool
包简介
php-resque worker pool manager
README 文档
README
Php resque pool is a port of resque-pool for managing php-resque workers. Given a config file, it manages your workers for you, starting up the appropriate number of workers for each worker type.
Benefits
- Less config - With a simple YAML file, you can start up a pool daemon.
- Monitoring - If a worker dies for some reason, php-resque-pool will start another.
- Easily change worker distribution - To change your worker counts just update the YAML file and send the manager a HUP signal.
How to use
YAML file config
Create a config/resque-pool.yml (or resque-pool.yml) with your worker
counts. The YAML file supports both using root level defaults as well as
environment specific overrides (RESQUE_ENV environment variables can be
used to determine environment). For example in config/resque-pool.yml:
foo: 1
bar: 2
"foo,bar,baz": 1
production:
"foo,bar,baz": 4
Start the pool manager
Then you can start the queues via:
bin/resque-pool --daemon --environment production
This will start up seven worker processes, one exclusively for the foo queue, two exclusively for the bar queue, and four workers looking at all queues in priority. With the config above, this is similar to if you ran the following:
QUEUES=foo php resque.php
QUEUES=bar php resque.php
QUEUES=bar php resque.php
QUEUES=foo,bar,baz php resque.php
QUEUES=foo,bar,baz php resque.php
QUEUES=foo,bar,baz php resque.php
QUEUES=foo,bar,baz php resque.php
The pool manager will stay around monitoring the resque worker parents, giving
three levels: a single pool manager, many worker parents, and one worker child
per worker (when the actual job is being processed). For example, ps -ef f | grep [r]esque (in Linux) might return something like the following:
resque 13858 1 0 13:44 ? S 0:02 resque-pool-manager: managing [13867, 13875, 13871, 13872, 13868, 13870, 13876]
resque 13867 13858 0 13:44 ? S 0:00 \_ resque-1.0: Waiting for foo
resque 13868 13858 0 13:44 ? S 0:00 \_ resque-1.0: Waiting for bar
resque 13870 13858 0 13:44 ? S 0:00 \_ resque-1.0: Waiting for bar
resque 13871 13858 0 13:44 ? S 0:00 \_ resque-1.0: Waiting for foo,bar,baz
resque 13872 13858 0 13:44 ? S 0:00 \_ resque-1.0: Forked 7481 at 1280343254
resque 7481 13872 0 14:54 ? S 0:00 \_ resque-1.0: Processing foo since 1280343254
resque 13875 13858 0 13:44 ? S 0:00 \_ resque-1.0: Waiting for foo,bar,baz
resque 13876 13858 0 13:44 ? S 0:00 \_ resque-1.0: Forked 7485 at 1280343255
resque 7485 13876 0 14:54 ? S 0:00 \_ resque-1.0: Processing bar since 1280343254
You can get similar output with pstree, or on some systems with ps auxd | grep [r]esque
Running as a daemon will currently output to stdout, although this will be configurable in the future.
SIGNALS
The pool manager responds to the following signals:
HUP- reload the config file, restart all workers.QUIT- gracefully shut down workers (viaQUIT) and shutdown the manager after all workers are done.INT- gracefully shut down workers (viaQUIT) and immediately shutdown managerTERM- immediately shut down workers (viaINT) and immediately shutdown manager (configurable via command line options)WINCH- (only when running as a daemon) sendQUITto each worker, but keep manager running (sendHUPto reload config and restart workers)USR1/USR2/CONT- pass the signal on to all worker parents (see Resque docs).
Use HUP to change the number of workers per worker type. Signals can be sent via the
kill command, e.g. kill -HUP $master_pid
Other Features
You can specify an alternate config file by setting the RESQUE_POOL_CONFIG or
with the --config command line option.
Contributors
- Your name here!
shonm/php-resque-pool 适用场景与选型建议
shonm/php-resque-pool 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.49k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2013 年 02 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 shonm/php-resque-pool 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shonm/php-resque-pool 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: 69736dea39c4a625f65c629a13c8ce4cb749f7ff
- 更新时间: 2013-02-01