-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple threaded worker for processing quant queue.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
|
||
} | ||
|