1
私はループで連続して実行するシェルスクリプトを持っています。cakephp 3.1 mysqlがなくなった
データベースでレコードをチェックし、必要に応じてレコードを変更します。私がいる
set_time_limit(0);
while(true){
try{
$this->out(mysql_ping());
$companies = $this->findCompanies();
$companies = $this->reduceCompanies($companies, $rules);
$this->processCompanies($companies);
}catch (\Exception $e){
Log::write('debug', $e->getMessage());
$this->out($e->getMessage());
}
sleep(3);
}
問題は、このスクリプトで[OK]を実行しているようだが、その後ランダムにスローされます。 私は再接続する例外キャッチにいくつかのものを入れて試してみた 「を2006年のMySQLサーバが立ち去りました」
}catch (\Exception $e){
if(!mysql_ping()){//tried
$this->connection->reconnect(); //also tried
$this->Company->getDatasource()->reconnect(); neither seem to work.
}}
どのようにデータベースに再接続するのですか?
私は同様の問題に直面しており、根本原因これは、理想的には起こらないはずです:( –