I have written a Zend Framework based cron service for parallel tasks, and ran into issues with the child threads sharing resources with the parent. I solved the database connection issue, but I'm now seeing periodic issues with Zend_Db_Table_Abstract
failing to save table metadata to metadata cache.
Failed saving metadata to metadataCache
I initialize the metadata cache during bootstrap. Rather than copying my code from the bootstrap and executing after forking, I thought that it might be better to call the Bootstrap->_init[...]
functions by using $application->bootstrap('[...]')
.
UPDATE
Because Zend_Controller_Front::getInstance()
is a Singleton, using it to get the bootstrap instance and call the functions that way returns me to the same issue with shared resources that I had already resolved.
I want to somehow keep this DRY while avoiding the issues with shared resources after forking.
Zend_Controller_Front is singleton, but its constructor is protected, so you can extend that simply by creating a class called, App_Controller_Front
in that create a method for getNewInstance(), which can call constructor without checking for existence. This way you can override the singleton behavior.