Skip to content

Commit

Permalink
Merge branch 'jjbubudi-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Phobetor committed Dec 4, 2015
2 parents dcc6e38 + 3bc4c8e commit 66d4de5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function getConfigTreeBuilder()

$rootNode
->children()
->scalarNode('worker_count')->defaultValue(1)->end()
->scalarNode('supervisor_instance_identifier')->defaultValue('symfony2')->end()
->end();
$this->addPaths($rootNode);
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/RabbitMqSupervisorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

$container->setParameter('phobetor_rabbitmq_supervisor.worker_count', $config['worker_count']);
$container->setParameter('phobetor_rabbitmq_supervisor.supervisor_instance_identifier', $config['supervisor_instance_identifier']);
$container->setParameter('phobetor_rabbitmq_supervisor.paths', $config['paths']);
$container->setParameter('phobetor_rabbitmq_supervisor.workspace', $config['paths']['workspace_directory']);
Expand Down
1 change: 1 addition & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
- "%phobetor_rabbitmq_supervisor.commands%"
- "%phobetor_rabbitmq_supervisor.consumers%"
- "%phobetor_rabbitmq_supervisor.multiple_consumers%"
- "%phobetor_rabbitmq_supervisor.worker_count%"

phobetor_rabbitmq_supervisor.supervisor_service:
class: "%phobetor_rabbitmq_supervisor.supervisor_service.class%"
Expand Down
11 changes: 9 additions & 2 deletions Services/RabbitMqSupervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class RabbitMqSupervisor
*/
private $multipleConsumers;

/**
* @var int
*/
private $workerCount;

/**
* Initialize Handler
*
Expand All @@ -54,8 +59,9 @@ class RabbitMqSupervisor
* @param array $commands
* @param array $consumers
* @param array $multipleConsumers
* @param int $workerCount
*/
public function __construct(Supervisor $supervisor, EngineInterface $templating, $kernelRootDir, array $paths, array $commands, $consumers, $multipleConsumers)
public function __construct(Supervisor $supervisor, EngineInterface $templating, $kernelRootDir, array $paths, array $commands, $consumers, $multipleConsumers, $workerCount)
{
$this->supervisor = $supervisor;
$this->templating = $templating;
Expand All @@ -64,6 +70,7 @@ public function __construct(Supervisor $supervisor, EngineInterface $templating,
$this->commands = $commands;
$this->consumers = $consumers;
$this->multipleConsumers = $multipleConsumers;
$this->workerCount = $workerCount;
}

/**
Expand Down Expand Up @@ -263,7 +270,7 @@ private function generateWorkerConfigurations($names, $command)
'kernelRootDir' => $this->kernelRootDir,
'workerOutputLog' => $this->paths['worker_output_log_file'],
'workerErrorLog' => $this->paths['worker_error_log_file'],
'numprocs' => 1,
'numprocs' => $this->workerCount,
'options' => array(
'startsecs' => '2',
'autorestart' => 'true',
Expand Down

0 comments on commit 66d4de5

Please sign in to comment.