Skip to content

Commit

Permalink
Added simple threaded worker for processing quant queue.
Browse files Browse the repository at this point in the history
  • Loading branch information
stooit committed Jun 14, 2021
1 parent 80a8ccd commit 68554b0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drush.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
quantcdn.commands:
class: \Drupal\quant\Commands\QuantDrushCommands
tags:
- { name: drush.command }
32 changes: 32 additions & 0 deletions src/Commands/QuantDrushCommands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Drupal\quant\Commands;

use Drush\Commands\DrushCommands;

/**
* A drush command file.
*
* @package Drupal\quant\Commands
*/
class QuantDrushCommands extends DrushCommands {

/**
* Drush command that executes the Quant queue.
*
* @command quant:run-queue
* @aliases quant-queue-run
* @option threads
* Number of threads to use (default 5)
* @usage quant:run-queue --threads=5
*/
public function message($options = ['threads' => 5]) {
$this->output()->writeln("Forking seed worker.");
for ($i=0; $i<$options['threads']; $i++) {
$cmd = 'drush queue:run quant_seed_worker';
$process = proc_open($cmd, array(), $pipes, NULL, NULL, array('bypass_shell' => TRUE));
}
}

}

0 comments on commit 68554b0

Please sign in to comment.