bugfix mine websocket periodic mysql calling
This commit is contained in:
@@ -2,17 +2,18 @@
|
||||
|
||||
namespace Mine\SeekerBundle\Periodic;
|
||||
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Gos\Bundle\WebSocketBundle\Periodic\PdoPeriodicPing;
|
||||
use Gos\Bundle\WebSocketBundle\Periodic\PeriodicInterface;
|
||||
use PDO;
|
||||
|
||||
class MinePeriodic implements PeriodicInterface
|
||||
{
|
||||
private $em;
|
||||
/** @var PdoPeriodicPing */
|
||||
private $ping;
|
||||
|
||||
public function __construct(EntityManager $entityManager)
|
||||
public function __construct(PdoPeriodicPing $ping)
|
||||
{
|
||||
$this->em = $entityManager;
|
||||
$this->ping = $ping;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,16 +23,7 @@ class MinePeriodic implements PeriodicInterface
|
||||
*/
|
||||
public function tick()
|
||||
{
|
||||
try {
|
||||
$connection = $this->em->getConnection();
|
||||
|
||||
if (false === $connection->ping()) {
|
||||
$connection->close();
|
||||
$connection->connect();
|
||||
}
|
||||
} catch(PDOException $ex) {
|
||||
throw PDOException::class;
|
||||
}
|
||||
$this->ping->tick();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,6 +31,6 @@ class MinePeriodic implements PeriodicInterface
|
||||
*/
|
||||
public function getTimeout()
|
||||
{
|
||||
return 777;
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,10 @@ services:
|
||||
|
||||
mineseeker.periodic:
|
||||
class: Mine\SeekerBundle\Periodic\MinePeriodic
|
||||
tags:
|
||||
- { name: gos_web_socket.periodic }
|
||||
arguments:
|
||||
doctrine: '@doctrine.orm.entity_manager'
|
||||
ping: '@gos_web_socket.pdo.periodic_ping'
|
||||
|
||||
mineseeker.topic_sample_service:
|
||||
class: Mine\SeekerBundle\Topic\MineseekerTopic
|
||||
|
||||
Reference in New Issue
Block a user