diff --git a/src/Command/HealthCheckJsonCommand.php b/src/Command/HealthCheckJsonCommand.php new file mode 100644 index 00000000..3edec3a0 --- /dev/null +++ b/src/Command/HealthCheckJsonCommand.php @@ -0,0 +1,45 @@ +setDescription('Returns a JSON with all health check checkers result merged like with /health/status route'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $collection = new HealthCollection(); + foreach ($this->healthCheckers as $checker) { + $checker->collect($collection); + } + + $output->writeln(json_encode($collection, JSON_PRETTY_PRINT)); + + return Command::SUCCESS; + } +} diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 45a1f9ac..83bd460b 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -7,5 +7,6 @@ +