2022-02-04 14:21:42 +01:00
|
|
|
<?php
|
|
|
|
|
2022-04-27 14:24:48 +02:00
|
|
|
namespace App\Controller;
|
2022-02-04 14:21:42 +01:00
|
|
|
|
2022-04-27 14:24:48 +02:00
|
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
2022-02-04 14:21:42 +01:00
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
2022-04-27 14:24:48 +02:00
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Component\HttpKernel\KernelInterface;
|
2022-02-04 14:21:42 +01:00
|
|
|
|
2022-04-27 14:24:48 +02:00
|
|
|
class SiteController extends AbstractController
|
2022-02-04 14:21:42 +01:00
|
|
|
{
|
2022-04-27 14:24:48 +02:00
|
|
|
|
|
|
|
public function healthAction(Request $request, ManagerRegistry $doctrine, KernelInterface $kernel)
|
2022-02-04 14:21:42 +01:00
|
|
|
{
|
2022-04-27 14:24:48 +02:00
|
|
|
$em = $doctrine->getManager();
|
|
|
|
$jobRepo = $em->getRepository('App:Job');
|
2022-02-04 14:21:42 +01:00
|
|
|
$return = [
|
|
|
|
"DaemonRunning" => file_exists($kernel->getCacheDir() . '/daemon-running.lock'),
|
|
|
|
"JobsTotal" => count($jobRepo->getAllJobs()),
|
|
|
|
"JobsDue" => count($jobRepo->getJobsDue()),
|
|
|
|
"JobsRunning" => count($jobRepo->getRunningJobs()),
|
|
|
|
"JobsFailing" => count($jobRepo->getFailingJobs()),
|
|
|
|
];
|
|
|
|
return new JsonResponse($return, $return['DaemonRunning'] ? 200 : 500);
|
|
|
|
}
|
|
|
|
}
|