M
M
Maxim Zhgulev2017-04-05 11:53:50
Yii
Maxim Zhgulev, 2017-04-05 11:53:50

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

I'm trying to get Yii2 Queue Extension on Yii2 Advanced App.
In common/config/main.php I wrote:
'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',
        ],
    ],

Created Job
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();
    }
}

In the controller action, where you need to add a job to the queue, I wrote:
Yii::$app->queue->push(new UploadJob([
    'projectId' => $model->id,
]));

I start the listener (if I don't start it, the problem is the same):
./yii queue/listen
The command line does not respond and seems to be hanging in the waiting mode, that is, the listener has started and is waiting, if I understand correctly.
I launch the action in the browser and when it comes to Yii::$app->queue->pushthe 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

1 answer(s)
S
sehav, 2018-04-18
@sehav

Are the channels in the console config and in the front one the same?
run
./yii queue/listen --verbose
output will be verbose

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question