I made a cron command using ScheduleEveryOtherMinute trait, however the scheduler crashes every second time it tries to create the job with Warning: PDOStatement::execute(): MySQL server has gone away exception.
A possible fix for this would running something like this every loop iteration:
if ($em->getConnection()->ping() === false) {
$em->getConnection()->close();
$em->getConnection()->connect();
}
If I recall correctly, the EntityManager doesn't get closed if you disconnect/connect the underlying connection manually so the rest of code should work without any changes.
If every loop iteration seems excessive then perhaps an option like --conn-ping-interval which will allow to define a custom interval to run the code above.
I made a cron command using
ScheduleEveryOtherMinute
trait, however the scheduler crashes every second time it tries to create the job withWarning: PDOStatement::execute(): MySQL server has gone away
exception.A possible fix for this would running something like this every loop iteration:
If I recall correctly, the
EntityManager
doesn't get closed if you disconnect/connect the underlying connection manually so the rest of code should work without any changes.If every loop iteration seems excessive then perhaps an option like
--conn-ping-interval
which will allow to define a custom interval to run the code above.Thoughts (I can make a PR)?