Giter Site home page Giter Site logo

Comments (1)

walkor avatar walkor commented on May 11, 2024 1

MySQL server has gone away 一般是由于mysql连接长时间不活跃被mysql服务端关闭。illuminate\database 内部有重连机制,这个warning可以忽略。

如果不想看到这个warning,你可以尝试将mysql服务端wait_timeout参数加大。

或者使用定时器,定时select数据,防止mysql连接被关闭,像下面这样。
创建文件 support/bootstrap/db/Heartbeat.php 如下:

<?php
namespace support\bootstrap\db;
use Webman\Bootstrap;
use support\Db;

class Heartbeat implements Bootstrap
{
    public static function start($worker)
    {
        \Workerman\Timer::add(30, function (){
            Db::select('select 1 limit 1');
        });
    }
}

config/bootstrap.php中加入如下代码。

return [
    省略...
    support\bootstrap\db\Heartbeat::class,
];

这样webman进程启时就会启动一个定时器,定时与mysql通讯,防止连接不活跃被断开。这里定时间隔时30秒,你可以根据mysql服务端wait_timeout参数设定的值修改定时间隔。

from webman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.