Answer the question
In order to leave comments, you need to log in
Yii2 Queue Extension (Gearman) hangs when trying to add a task. What am I doing wrong?
Installed gearman-job-server from the standard repository on a Debian 8 server. Now top shows 6 gearmand processes.
Through PECL, I installed the gearman.so extension and added php.ini to all configs.
phpinfo() shows the presence of gearman:
extension version 1.1.2
libgearman version 1.0.6
Default TCP Host localhost
Default TCP Port 4730
'bootstrap' => ['queue'],
'components' => [
'queue' => [
'class' => \zhuravljov\yii\queue\gearman\Queue::class,
'as log' => \zhuravljov\yii\queue\LogBehavior::class,
'host' => 'localhost',
'port' => 4730,
'channel' => 'my_queue',
],
],
namespace common\jobs;
use common\models\Project;
use yii\base\Object;
class UploadJob extends Object implements \zhuravljov\yii\queue\Job
{
public $projectId;
public function run()
{
$project = Project::findOne($this->projectId);
$project->status = Project::STATUS_PROCESSING;
$project->save();
\Yii::info('here will be upload job for project ' . $project->name);
$project->status = Project::STATUS_READY;
$project->save();
}
}
Yii::$app->queue->push(new UploadJob([
'projectId' => $model->id,
]));
./yii queue/listen
Yii::$app->queue->push
the site it hangs (the rest of the sites work) and I have to restart the apache2 daemon, and disable the listener via Ctrl + C. gearmand.log is clean from the word at all.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question