0
我開始使用php-resque(https://github.com/chrisboulton/php-resque)以及php和mysql服務器。我看到工作人員發現「MySQL服務器已經消失」的錯誤。php-reque:worker「MySQL服務器已經消失」
工作排隊代碼:
if ($request->command == 'custom_script') {
//error_log("before queue");
Resque::enqueue($queue, 'AsyncTest', array('text'=>'yolo'));
//error_log("after queue");
}
作業類:
class AsyncTest{
public function setUp() {
# Set up something before perform, like establishing a database connection
$mysql = Mysql::getInstance();
EH::setErrorHandler();
}
public function perform()
{
// $mysql = Mysql::getInstance();
// EH::setErrorHandler();
//error_log($this->args['text']);
$haiku_step_query= $mysql->query("SELECT id FROM haiku LIMIT 10 OFFSET 1");
$row = $mysql->fetch_assoc($haiku_step_query);
$haiku_id = $row['id'];
}
public function tearDown() {
# Run after perform, like closing resources
}
}
之我見 「MySQL服務器消失」 的錯誤消息:
MySQL ERROR №2006 MySQL server has gone away[qs:SELECT id FROM haiku LIMIT 10 OFFSET 1]
(/var/www/html/haiku_server/vendor/chrisboulton/php-resque/resque.php line 77
Resque_Worker->work(5) >> /var/www/html/haiku_server/vendor/chrisboulton/php-resque/lib/Resque/Worker.php line 199
Resque_Worker->perform(Object) >> /var/www/html/haiku_server/vendor/chrisboulton/php-resque/lib/Resque/Worker.php line 237
Resque_Job->perform() >> /var/www/html/haiku_server/vendor/chrisboulton/php-resque/lib/Resque/Job.php line 182
AsyncTest->perform() >> /var/www/html/haiku_server/includes/bgJobs/AsyncThreads.php line 48
Mysql->query("SELECT id FROM haiku LIMIT 10 OFFSET 1") >> /var/www/html/haiku_server/includes/Mysql.class.php line 113 )
請注意,這不發生,那是MySQL工作正常,當我做的操作無白皮書 - resque,如:
if ($request->command == 'custom_script') {
$mysql = Mysql::getInstance();
EH::setErrorHandler();
$haiku_step_query= $mysql->query("SELECT id FROM haiku LIMIT 10 OFFSET 1");
$row = $mysql->fetch_assoc($haiku_step_query);
$haiku_id = $row['id'];
}
大聲笑,這個線程有我與php-resque的開發人員之間的互動,他的解決方案確實解決了我的問題。所以,可能會接受你的答案。 –