Doctrine2 connection timeout in daemon

后端 未结 5 1548

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:05

    I'm using this in my symfony2 beanstalkd daemon Command worker:

    $em = $this->getContainer()->get('doctrine')->getManager();
    if ($em->getConnection()->ping() === false) {
        $em->getConnection()->close();
        $em->getConnection()->connect();
    }
    

提交回复
热议问题