ed-smartass / yii2-queue-worker
Adding ability to start and manage yii2-queue workers
Installs: 66
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.14
- yiisoft/yii2-queue: ^2.0
README
Adding ability to start and manage yii2-queue workers
Installation
The preferred way to install this extension is through composer.
- Run
composer require ed-smartass/yii2-queue-worker
- Apply migrations
php yii migrate --migrationPath=@vendor/ed-smartass/yii2-queue-worker/migrations
or add to console config and run migration
return [ // ... 'controllerMap' => [ // ... 'migrate' => [ 'class' => 'yii\console\controllers\MigrateController', 'migrationPath' => [ '@console/migrations', // Default migration folder '@vendor/ed-smartass/yii2-queue-worker/migrations' ] ] // ... ] // ... ];
- Add behavior to queue config
return [ // ... 'components' => [ // ... 'queue' => [ 'class' => 'yii\queue\db\Queue', 'mutex' => 'yii\mutex\MysqlMutex', // ... 'as worker' => 'Smartass\Yii2QueueWorker\QueueWorkerBehavior' ] // ... ] // ... ];
- Add module to your application (optional)
return [ // ... 'modules' => [ // ... 'queue-worker' => [ 'class' => 'Smartass\Yii2QueueWorker\module\Module', // If you want change view files just copy it from `vendor/ed-smartass/yii2-queue-worker/module/views` // to `@app/views/queue-worke` and set: // 'viewPath' => '@app/views/queue-worker' ] // ... ] // ... ];
Usage
All started workers you cant find at queue_worker
table.
Manage workers (if you config module): https:://your-site.com/queue-workers
.
To start worker
Yii::$app->queue->start($timeout = 3, $yiiPath = '@app/../yii', $params = '--verbose --color');
or
QueueWorkerBehavior::startComponent($component = 'queue', $timeout = 3, $yiiPath = '@app/../yii', $params = '--verbose --color');
To stop worker
Yii::$app->queue->stop($worker_id = null);
or
QueueWorkerBehavior::stopComponent($component = null, $worker_id = null, $db = 'db', $table = '{{%queue_worker}}');
If worker_id
is null
all workers will stop.