作者:白云下6_136 | 来源:互联网 | 2023-05-29 17:07
123456789101112131415161718$db = new swoole_mysql;$serv = new swoole_http_server("127.0.0.1", 9501
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| $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?
解决了,加了定时器发送心跳