Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for compatibility with symfony 6 #69

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ protected function addPaths(ArrayNodeDefinition $node)
->arrayNode('paths')
->addDefaultsIfNotSet()
->children()
->scalarNode('workspace_directory')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/')->end()
->scalarNode('configuration_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisord.conf')->end()
->scalarNode('pid_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisor.pid')->end()
->scalarNode('sock_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisor.sock')->end()
->scalarNode('log_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisord.log')->end()
->scalarNode('worker_configuration_directory')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/worker/')->end()
->scalarNode('worker_output_log_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/logs/stdout.log')->end()
->scalarNode('worker_error_log_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/logs/stderr.log')->end()
->scalarNode('workspace_directory')->defaultValue('%kernel.project_dir%/supervisor/%kernel.environment%/')->end()
->scalarNode('configuration_file')->defaultValue('%kernel.project_dir%/supervisor/%kernel.environment%/supervisord.conf')->end()
->scalarNode('pid_file')->defaultValue('%kernel.project_dir%/supervisor/%kernel.environment%/supervisor.pid')->end()
->scalarNode('sock_file')->defaultValue('%kernel.project_dir%/supervisor/%kernel.environment%/supervisor.sock')->end()
->scalarNode('log_file')->defaultValue('%kernel.project_dir%/supervisor/%kernel.environment%/supervisord.log')->end()
->scalarNode('worker_configuration_directory')->defaultValue('%kernel.project_dir%/supervisor/%kernel.environment%/worker/')->end()
->scalarNode('worker_output_log_file')->defaultValue('%kernel.project_dir%/supervisor/%kernel.environment%/logs/stdout.log')->end()
->scalarNode('worker_error_log_file')->defaultValue('%kernel.project_dir%/supervisor/%kernel.environment%/logs/stderr.log')->end()
->scalarNode('php_executable')->defaultValue('php')->end()
->end()
->end()
Expand Down
5 changes: 4 additions & 1 deletion DependencyInjection/RabbitMqSupervisorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ public function prepend(ContainerBuilder $container)
}
}

public function getAlias()
/**
* @return string
*/
public function getAlias(): string
{
return 'rabbit_mq_supervisor';
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function registerBundles()
}
```

Symfony 5:
Symfony 5 & 6:

```php
// config/bundles.php
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
- "%phobetor_rabbitmq_supervisor.rpc_servers%"
- "%phobetor_rabbitmq_supervisor.config%"
- "%phobetor_rabbitmq_supervisor.sock_file_permissions%"
- "%kernel.root_dir%"
- "%kernel.project_dir%"
- "%kernel.environment%"

phobetor_rabbitmq_supervisor.supervisor_service:
Expand Down
15 changes: 13 additions & 2 deletions Services/RabbitMqSupervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ private function generateWorkerConfigurations($names, $baseCommand)
'stopsignal' => $this->getConsumerWorkerOption($name, 'stopsignal'),
'stopasgroup' => $this->transformBoolToString($this->getConsumerWorkerOption($name, 'stopasgroup')),
'stopwaitsecs' => $this->getConsumerWorkerOption($name, 'stopwaitsecs'),
'stdout_logfile' => $this->paths['worker_output_log_file'],
'stderr_logfile' => $this->paths['worker_error_log_file']
'stdout_logfile' => $this->workerSpecificLogFile($this->paths['worker_output_log_file'], $name),
'stderr_logfile' => $this->workerSpecificLogFile($this->paths['worker_error_log_file'], $name)
);

if ($this->getGeneralConsumerWorkerOption('user')) {
Expand All @@ -408,6 +408,17 @@ private function generateWorkerConfigurations($names, $baseCommand)
}
}

private function workerSpecificLogFile($originalFileName, $suffix) {
$extension = ".log";
$pos = strrpos($originalFileName, $extension);

if ($pos === false) {
return $originalFileName;
}

return substr_replace($originalFileName, "_" . $suffix, $pos, 0);
}

private function getConsumerOption($consumer, $key)
{
$option = $this->getIndividualConsumerOption($consumer, $key);
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"symfony2",
"symfony3",
"symfony4",
"symfony5"
"symfony5",
"symfony6"
],
"homepage": "https://github.com/Phobetor/rabbitmq-supervisor-bundle",
"authors": [
Expand All @@ -21,9 +22,9 @@
}
],
"require": {
"symfony/framework-bundle": "~2.5|~3.0|~4.0|~5.0",
"symfony/console": "~2.5|~3.0|~4.0|~5.0",
"symfony/process": "~2.5|~3.0|~4.0|~5.0"
"symfony/framework-bundle": "~2.5|~3.0|~4.0|~5.0|~6.0",
"symfony/console": "~2.5|~3.0|~4.0|~5.0|~6.0",
"symfony/process": "~2.5|~3.0|~4.0|~5.0|~6.0"
},
"suggest": {
"php-amqplib/rabbitmq-bundle": "The rabbitmq bundle for symfony which this bundle takes the consumer information from",
Expand Down