简体   繁体   English

如何手动修剪和重启php-resque工作者

[英]How to manually prune and restart php-resque workers

Very frequently php-Resque workers will be stuck on a job for days, and eventually all the workers gets stuck and the site stops working.The php-resque library was installed using Composer. 很多时候,php-Resque工作人员将被困在工作上几天,最终所有工作人员都被困住,网站停止工作。使用Composer安装了php-resque库。

Question: I want to do the pruning manually. 问题:我想手动修剪。 How do I access this function pruneDeadWorkers() ? 如何访问此函数pruneDeadWorkers() And if dead workers are found, how do I restart them? 如果找到死亡工人,我该如何重新启动它们?

View Source 查看来源

在此输入图像描述

To prune the workers manually, include the vendor/chrisboulton/php-resque/lib/Resque/Worker.php file, instantiate a Worker, then call pruneDeadWorkers(); 要手动修剪worker,请包含vendor / chrisboulton / php-resque / lib / Resque / Worker.php文件,实例化Worker,然后调用pruneDeadWorkers();

<?php 
include 'vendor/chrisboulton/php-resque/lib/Resque/Worker.php'; // If you're not already using composer autoloader

$worker = new Worker('default'); // the argument doesn't matter
$worker->pruneDeadWorkers();

php-resque is not shipped with a function to restart workers, take a look at fresque for that. php-resque没有附带重启工作人员的功能,请看一下fresque

To avoid having dead workers, compile your php with pcntl_fork , to execute your jobs in a fork, and isolating them from the workers. 为了避免死亡工人,使用pcntl_fork编译你的php,在fork中执行你的工作,并将它们与工人隔离。

first find worker list : Resque_Worker::all(); 首先找到工人列表: Resque_Worker::all(); this contain workers id according to php-resque doc type in command line 这包含在命令行中根据php-resque doc类型的worker id

`kill workers id`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM