$db = new swoole_mysql;
$serv = new swoole_http_server("127.0.0.1", 9501);
$serv->on('WorkerStart', function(swoole_server $server) {
global $db;
$db->connect($db->server, function($db, $r) {
if ($r === false) {
var_dump($db->connect_errno, $db->connect_error);
die;
}
});
});
$serv->on('Request', function($request, $response) {
global $db;
$db->query($sql, function(swoole_mysql $db, $r) {
........
});
}
過一段時間,mysql連接就close了,怎麼才能永遠不close?
斷線重連或心跳機制都行