diegodevgroup/beanworkers
Composer 安装命令:
composer require diegodevgroup/beanworkers
包简介
A way to dynamically control the number of processes that Supervisord will have running at any given time
README 文档
README
This is a command line script to automatically update the number of processes in supervisord dynamically based on number of ready jobs in a beanstalk tube(s)
Usage is simple, but there are assumptions made. Please ensure you have a backup before attempting to use this code.
Assumptions
- Supervisord programs are listed individually in separate ini files.
- You are running this as a user that has access to edit ini files and run
supervisorctl
Example
$pheanstalk = new \Pheanstalk\Pheanstalk("$host:$port");
$worker = new Supervisord\Beanstalkd\Workers($pheanstalk, '/usr/bin/supervisorctl');
$worker->addIniFile('default', '/etc/supervisord.d/default.ini');
$worker->addRules('default', ['minimum_jobs' => 0, 'required_workers' => 1]);
$worker->addRules('default', ['minimum_jobs' => 10, 'required_workers' => 3]);
$worker->run();
In the above example, the worker gets the stats of the default tube, and if there are less than 10 jobs currently ready, it will set the numprocs to 1. If there are 10 or more, it will set numprocs to 3. It will then update supervisord via supervisorctl.
Add to cron
Your script should probably run every minute.
Add as many rules as you like, just keep your resources in mind as you do so.
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-07