@@ -34,40 +34,40 @@ discard block |
||
34 | 34 | |
35 | 35 | class DefaultController extends AbstractController { |
36 | 36 | |
37 | - private CachedTenantContextInterface $tenantContext; |
|
38 | - private MetaFactoryInterface $metaFactory; |
|
39 | - private Context $templateEngineContext; |
|
40 | - private RouteFactoryInterface $routeFactory; |
|
41 | - |
|
42 | - public function __construct( |
|
43 | - CachedTenantContextInterface $tenantContext, |
|
44 | - MetaFactoryInterface $metaFactory, |
|
45 | - Context $templateEngineContext, |
|
46 | - RouteFactoryInterface $routeFactory |
|
47 | - ) { |
|
37 | + private CachedTenantContextInterface $tenantContext; |
|
38 | + private MetaFactoryInterface $metaFactory; |
|
39 | + private Context $templateEngineContext; |
|
40 | + private RouteFactoryInterface $routeFactory; |
|
41 | + |
|
42 | + public function __construct( |
|
43 | + CachedTenantContextInterface $tenantContext, |
|
44 | + MetaFactoryInterface $metaFactory, |
|
45 | + Context $templateEngineContext, |
|
46 | + RouteFactoryInterface $routeFactory |
|
47 | + ) { |
|
48 | 48 | $this->tenantContext = $tenantContext; |
49 | 49 | $this->metaFactory = $metaFactory; |
50 | 50 | $this->templateEngineContext = $templateEngineContext; |
51 | 51 | $this->routeFactory = $routeFactory; |
52 | - } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @Route("/", methods={"GET","POST"}, name="homepage") |
|
56 | - */ |
|
57 | - public function indexAction(Request $request): Response { |
|
54 | + /** |
|
55 | + * @Route("/", methods={"GET","POST"}, name="homepage") |
|
56 | + */ |
|
57 | + public function indexAction(Request $request): Response { |
|
58 | 58 | /** @var TenantInterface $currentTenant */ |
59 | 59 | $currentTenant = $this->tenantContext->getTenant(); |
60 | 60 | $route = $currentTenant->getHomepage(); |
61 | 61 | |
62 | 62 | if (null === $route) { |
63 | - /** @var RouteInterface $route */ |
|
64 | - $route = $this->routeFactory->create(); |
|
65 | - $route->setStaticPrefix('/'); |
|
66 | - $route->setName('Homepage'); |
|
67 | - $route->setType('content'); |
|
68 | - $route->setTemplateName('index.html.twig'); |
|
69 | - $route->setCacheTimeInSeconds(360); |
|
70 | - $request->attributes->set(DynamicRouter::ROUTE_KEY, $route); |
|
63 | + /** @var RouteInterface $route */ |
|
64 | + $route = $this->routeFactory->create(); |
|
65 | + $route->setStaticPrefix('/'); |
|
66 | + $route->setName('Homepage'); |
|
67 | + $route->setType('content'); |
|
68 | + $route->setTemplateName('index.html.twig'); |
|
69 | + $route->setCacheTimeInSeconds(360); |
|
70 | + $request->attributes->set(DynamicRouter::ROUTE_KEY, $route); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $this->templateEngineContext->setCurrentPage($this->metaFactory->create($route)); |
@@ -76,63 +76,63 @@ discard block |
||
76 | 76 | $response->headers->set('Content-Type', 'text/html; charset=UTF-8'); |
77 | 77 | |
78 | 78 | return $this->render('index.html.twig', [], $response); |
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @Route("/api/system/health", methods={"GET"}, name="system_health") |
|
83 | - * @IsGranted(null) |
|
84 | - */ |
|
85 | - public function healthCheck( |
|
86 | - Connection $connection, |
|
87 | - ElasticaClient $elasticaClient, |
|
88 | - AdapterInterface $cachePool, |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @Route("/api/system/health", methods={"GET"}, name="system_health") |
|
83 | + * @IsGranted(null) |
|
84 | + */ |
|
85 | + public function healthCheck( |
|
86 | + Connection $connection, |
|
87 | + ElasticaClient $elasticaClient, |
|
88 | + AdapterInterface $cachePool, |
|
89 | 89 | ?AMQPStreamConnection $amqpConnection = null |
90 | - ): JsonResponse { |
|
91 | - $status = [ |
|
92 | - 'application_name' => 'Publisher', |
|
93 | - 'postgres' => 'red', |
|
94 | - 'elastic' => 'red', |
|
95 | - 'memcached' => 'red', |
|
96 | - 'rabbitmq' => 'red', |
|
97 | - ]; |
|
98 | - |
|
99 | - // Check Postgres |
|
100 | - try { |
|
101 | - $connection->connect(); |
|
102 | - if ($connection->isConnected()) { |
|
103 | - $status['postgres'] = 'green'; |
|
104 | - } |
|
105 | - } catch (\Throwable $e) {} |
|
106 | - |
|
107 | - // Check Elasticsearch |
|
108 | - try { |
|
109 | - $elasticaClient->getStatus(); |
|
110 | - $status['elastic'] = 'green'; |
|
111 | - } catch (\Throwable $e) {} |
|
112 | - |
|
113 | - // Check Memcached (Symfony Cache) |
|
114 | - try { |
|
115 | - $cacheKey = 'health_check_' . uniqid(); |
|
116 | - $cachePool->save($cachePool->getItem($cacheKey)->set('ok')); |
|
117 | - $cachePool->deleteItem($cacheKey); |
|
118 | - $status['memcached'] = 'green'; |
|
119 | - } catch (\Throwable $e) {} |
|
120 | - |
|
121 | - // Check RabbitMQ |
|
122 | - try { |
|
123 | - $amqp = new \AMQPConnection([ |
|
124 | - 'host' => 'localhost', |
|
125 | - 'port' => 5672, |
|
126 | - 'login' => 'guest', |
|
127 | - 'password' => 'guest', |
|
128 | - 'vhost' => '/', |
|
129 | - ]); |
|
130 | - $amqp->connect(); |
|
131 | - if ($amqp->isConnected()) { |
|
132 | - $status['rabbitmq'] = 'green'; |
|
133 | - } |
|
134 | - } catch (\Throwable $e) {} |
|
135 | - |
|
136 | - return new JsonResponse($status); |
|
137 | - } |
|
90 | + ): JsonResponse { |
|
91 | + $status = [ |
|
92 | + 'application_name' => 'Publisher', |
|
93 | + 'postgres' => 'red', |
|
94 | + 'elastic' => 'red', |
|
95 | + 'memcached' => 'red', |
|
96 | + 'rabbitmq' => 'red', |
|
97 | + ]; |
|
98 | + |
|
99 | + // Check Postgres |
|
100 | + try { |
|
101 | + $connection->connect(); |
|
102 | + if ($connection->isConnected()) { |
|
103 | + $status['postgres'] = 'green'; |
|
104 | + } |
|
105 | + } catch (\Throwable $e) {} |
|
106 | + |
|
107 | + // Check Elasticsearch |
|
108 | + try { |
|
109 | + $elasticaClient->getStatus(); |
|
110 | + $status['elastic'] = 'green'; |
|
111 | + } catch (\Throwable $e) {} |
|
112 | + |
|
113 | + // Check Memcached (Symfony Cache) |
|
114 | + try { |
|
115 | + $cacheKey = 'health_check_' . uniqid(); |
|
116 | + $cachePool->save($cachePool->getItem($cacheKey)->set('ok')); |
|
117 | + $cachePool->deleteItem($cacheKey); |
|
118 | + $status['memcached'] = 'green'; |
|
119 | + } catch (\Throwable $e) {} |
|
120 | + |
|
121 | + // Check RabbitMQ |
|
122 | + try { |
|
123 | + $amqp = new \AMQPConnection([ |
|
124 | + 'host' => 'localhost', |
|
125 | + 'port' => 5672, |
|
126 | + 'login' => 'guest', |
|
127 | + 'password' => 'guest', |
|
128 | + 'vhost' => '/', |
|
129 | + ]); |
|
130 | + $amqp->connect(); |
|
131 | + if ($amqp->isConnected()) { |
|
132 | + $status['rabbitmq'] = 'green'; |
|
133 | + } |
|
134 | + } catch (\Throwable $e) {} |
|
135 | + |
|
136 | + return new JsonResponse($status); |
|
137 | + } |
|
138 | 138 | } |