Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d29b84ec78 | |||
| ccce0303c3 |
@@ -5,6 +5,7 @@ namespace App\Controller;
|
|||||||
use App\Download\Framework\Repository\DownloadRepository;
|
use App\Download\Framework\Repository\DownloadRepository;
|
||||||
use App\Monitor\Action\Command\MonitorTvShowCommand;
|
use App\Monitor\Action\Command\MonitorTvShowCommand;
|
||||||
use App\Monitor\Action\Handler\MonitorTvShowHandler;
|
use App\Monitor\Action\Handler\MonitorTvShowHandler;
|
||||||
|
use App\Monitor\Framework\Scheduler\MonitorDispatcher;
|
||||||
use App\Tmdb\Tmdb;
|
use App\Tmdb\Tmdb;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -30,9 +31,9 @@ final class IndexController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/test', name: 'app_test')]
|
#[Route('/test', name: 'app_test')]
|
||||||
public function test()
|
public function test(MonitorDispatcher $dispatcher): Response
|
||||||
{
|
{
|
||||||
$result = $this->monitorTvShowHandler->handle(new MonitorTvShowCommand(355));
|
$dispatcher();
|
||||||
return $this->json($result);
|
return new Response();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ use App\Monitor\Action\Handler\AddMonitorHandler;
|
|||||||
use App\Monitor\Action\Handler\DeleteMonitorHandler;
|
use App\Monitor\Action\Handler\DeleteMonitorHandler;
|
||||||
use App\Monitor\Action\Input\AddMonitorInput;
|
use App\Monitor\Action\Input\AddMonitorInput;
|
||||||
use App\Monitor\Action\Input\DeleteMonitorInput;
|
use App\Monitor\Action\Input\DeleteMonitorInput;
|
||||||
|
use App\Monitor\Framework\Scheduler\MonitorDispatcher;
|
||||||
use App\Util\Broadcaster;
|
use App\Util\Broadcaster;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Mercure\HubInterface;
|
use Symfony\Component\Mercure\HubInterface;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
@@ -50,4 +52,15 @@ class ApiController extends AbstractController
|
|||||||
'message' => $response
|
'message' => $response
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/api/monitor/dispatch', name: 'api_monitor_dispatch', methods: ['GET'])]
|
||||||
|
public function dispatch(MonitorDispatcher $dispatcher): Response
|
||||||
|
{
|
||||||
|
$dispatcher();
|
||||||
|
|
||||||
|
return $this->json([
|
||||||
|
'status' => 200,
|
||||||
|
'message' => 'Manually dispatched MonitorDispatcher'
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,12 @@ class MonitorDispatcher
|
|||||||
|
|
||||||
private function cleanupStuckMonitors(): void
|
private function cleanupStuckMonitors(): void
|
||||||
{
|
{
|
||||||
|
$hoursStuck = 4;
|
||||||
$monitors = $this->monitorRepository->findBy(['status' => 'In Progress']);
|
$monitors = $this->monitorRepository->findBy(['status' => 'In Progress']);
|
||||||
foreach ($monitors as $monitor) {
|
foreach ($monitors as $monitor) {
|
||||||
// Reset the status to active so it will be executed again
|
// Reset the status to active so it will be executed again
|
||||||
if ($monitor->getLastSearch()->diffInHours(Carbon::today()) > 6) {
|
if ($monitor->getLastSearch()->diffInHours(Carbon::today()) > $hoursStuck) {
|
||||||
|
$this->logger->info('[MonitorDispatcher] Cleaning up monitor: ' . $monitor->getId() . ' (' . $monitor->getTitle() . '), resetting status to \'Active\' from \''. $monitor->getStatus() .'\' after being stuck for ' . $hoursStuck . ' hours.');
|
||||||
$monitor->setStatus('Active');
|
$monitor->setStatus('Active');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user