From a936f87c6c536e0f152482c0a2b0bb6d65e6ef47 Mon Sep 17 00:00:00 2001 From: ablackburn-ic Date: Fri, 3 Mar 2023 17:24:16 -0500 Subject: [PATCH 1/5] Update for compatibility with symfony 6 --- README.md | 2 +- composer.json | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) 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/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", From 2e36b39a8262c6eca3b997c0de3e0fe9731319d7 Mon Sep 17 00:00:00 2001 From: ablackburn-ic Date: Tue, 28 Mar 2023 11:14:40 -0400 Subject: [PATCH 2/5] getAlias() must be compatible with Symfony\Component\DependencyInjection\Extension\Extension::getAlias() --- DependencyInjection/RabbitMqSupervisorExtension.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DependencyInjection/RabbitMqSupervisorExtension.php b/DependencyInjection/RabbitMqSupervisorExtension.php index 88b5fb2..e09ff50 100644 --- a/DependencyInjection/RabbitMqSupervisorExtension.php +++ b/DependencyInjection/RabbitMqSupervisorExtension.php @@ -94,6 +94,9 @@ public function prepend(ContainerBuilder $container) } } + /** + * @return string + */ public function getAlias() { return 'rabbit_mq_supervisor'; From eeb866af6768245c43c0aafbbe5026d1782939e9 Mon Sep 17 00:00:00 2001 From: ablackburn-ic Date: Tue, 28 Mar 2023 11:18:02 -0400 Subject: [PATCH 3/5] getAlias() compatibility --- DependencyInjection/RabbitMqSupervisorExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/RabbitMqSupervisorExtension.php b/DependencyInjection/RabbitMqSupervisorExtension.php index e09ff50..af1b10f 100644 --- a/DependencyInjection/RabbitMqSupervisorExtension.php +++ b/DependencyInjection/RabbitMqSupervisorExtension.php @@ -97,7 +97,7 @@ public function prepend(ContainerBuilder $container) /** * @return string */ - public function getAlias() + public function getAlias(): string { return 'rabbit_mq_supervisor'; } From 84faf7e78a171fed675e945a219e696be0a79ba3 Mon Sep 17 00:00:00 2001 From: ablackburn-ic Date: Tue, 28 Mar 2023 11:34:31 -0400 Subject: [PATCH 4/5] root_dir has been deprecated --- DependencyInjection/Configuration.php | 16 ++++++++-------- Resources/config/services.yml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) 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/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: From a0f3954133a20b2d4be9f063736b8cd3152632a8 Mon Sep 17 00:00:00 2001 From: ablackburn-ic Date: Fri, 23 Jun 2023 10:53:34 -0400 Subject: [PATCH 5/5] each worker gets its own log file --- Services/RabbitMqSupervisor.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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);