I have written a Zend Framework based cron service for parallel tasks based on these two blog articles:
- Cron tasks in Zend Framework apps
- Zend Framework Cron Tasks in Parallel
In summary, the cron services uses pcntl_fork()
to spawn the tasks in parallel.
Running a single task with the service works without issues, but when I add a second task, I get this MySQL error:
General error: 2006 MySQL server has gone away
My best guess is that a child thread ends before the other and the MySQL connection is implicitly closed. If this is the case, how do I ensure that the connection stays open until the parent thread closes?