PWE keep db connection up
This commit is contained in:
parent
1cacbbc08f
commit
99b0714850
|
@ -439,6 +439,9 @@ abstract class WebSocketServer
|
||||||
if ((time() - $this->lastTickTimestamp) > $this->tickInterval) {
|
if ((time() - $this->lastTickTimestamp) > $this->tickInterval) {
|
||||||
$this->lastTickTimestamp = time();
|
$this->lastTickTimestamp = time();
|
||||||
$this->tick();
|
$this->tick();
|
||||||
|
|
||||||
|
// Keep connection with DB active.
|
||||||
|
$this->dbHearthbeat();
|
||||||
}
|
}
|
||||||
|
|
||||||
socket_select($read, $write, $except, 0, $this->timeout);
|
socket_select($read, $write, $except, 0, $this->timeout);
|
||||||
|
@ -1530,4 +1533,25 @@ abstract class WebSocketServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps db connection opened.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function dbHearthbeat()
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
\hd($config['dbconnection']);
|
||||||
|
|
||||||
|
if (isset($config['dbconnection']) === false
|
||||||
|
|| mysqli_ping($config['dbconnection']) === false
|
||||||
|
) {
|
||||||
|
// Retry connection.
|
||||||
|
db_select_engine();
|
||||||
|
$config['dbconnection'] = db_connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue