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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user