我正在用 YII2 编写一个控制台应用程序。此应用程序必须运行很长时间。在 yii.php 中配置执行时间和 mysql 连接时间如下:
set_time_limit(0);
ini_set("memory_limit", -1);
ini_set('mysql.connect_timeout', 6000);
ini_set('default_socket_timeout', 6000);
我的应用程序 Controller updater
和一个操作 hook
。我像这样通过 SSH 运行此操作:
nohup php /path/to/project/yii updater/hook &
30 分钟后,此进程被终止。在 nohup.out
文件中,我检测到这样的错误:
Error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
如何修复此错误。请帮我! 以及如何编写长时间运行的应用程序(php和mysql,yii2)正确。
最佳答案
你必须设置 user abort true ignore_user_abort(1); ignore-user-abort
关于php - 在 YII2 中检查 mysql 连接的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33320202/