diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index d5f211b..87737d2 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -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() diff --git a/DependencyInjection/RabbitMqSupervisorExtension.php b/DependencyInjection/RabbitMqSupervisorExtension.php index 88b5fb2..af1b10f 100644 --- a/DependencyInjection/RabbitMqSupervisorExtension.php +++ b/DependencyInjection/RabbitMqSupervisorExtension.php @@ -94,7 +94,10 @@ public function prepend(ContainerBuilder $container) } } - public function getAlias() + /** + * @return string + */ + public function getAlias(): string { return 'rabbit_mq_supervisor'; } diff --git a/README.md b/README.md index f6dab7f..4887a92 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ public function registerBundles() } ``` -Symfony 5: +Symfony 5 & 6: ```php // config/bundles.php diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 1374d6b..9d97e41 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -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: diff --git a/Services/RabbitMqSupervisor.php b/Services/RabbitMqSupervisor.php index 636a038..aafc284 100644 --- a/Services/RabbitMqSupervisor.php +++ b/Services/RabbitMqSupervisor.php @@ -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')) { @@ -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); diff --git a/composer.json b/composer.json index a97bed5..ca1d739 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ "symfony2", "symfony3", "symfony4", - "symfony5" + "symfony5", + "symfony6" ], "homepage": "https://github.com/Phobetor/rabbitmq-supervisor-bundle", "authors": [ @@ -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",