Doctrine2 connection timeout in daemon

后端 未结 5 1534

I have a long running daemon (Symfony2 Command) that gets work off a work queue in Redis, and performs those jobs and writes to the database using the orm.

I noticed

5条回答
  •  粉色の甜心
    2020-12-30 03:02

    In your daemon you can add method to restart the connection possibly before every query. I was facing similar problmes using gaerman worker:

    I keep me connection data in zend registry so it looks like this:

    private function resetDoctrineConnection() {
        $doctrineManager = Doctrine_Manager::getInstance();
        $doctrineManager->reset();
        $dsn = Zend_Registry::get('dsn');
        $manager = Doctrine_Manager::getInstance();
        $manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
        Doctrine_Manager::connection($dsn, 'doctrine');
    }
    

    If it is damenon you need perhaps call it statically.

提交回复
热议问题