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