Esempio n. 1
0
 /**
  * @keepalive
  */
 public function startMaintenance()
 {
     $clockwork = new CM_Clockwork_Manager();
     $storage = new CM_Clockwork_Storage_FileSystem('search-maintenance');
     $storage->setServiceManager(CM_Service_Manager::getInstance());
     $clockwork->setStorage($storage);
     $clockwork->registerCallback('search-index-update', '1 minute', array($this, 'update'));
     $clockwork->registerCallback('search-index-optimize', '1 hour', array($this, 'optimize'));
     $clockwork->start();
 }
Esempio n. 2
0
 /**
  * @param string    $dateTimeString
  * @param Closure[] $callbacks
  */
 protected function _registerClockworkCallbacks($dateTimeString, $callbacks)
 {
     foreach ($callbacks as $name => $callback) {
         $transactionName = 'cm ' . static::getPackageName() . ' start: ' . $name;
         $this->_clockworkManager->registerCallback($name, $dateTimeString, function () use($transactionName, $callback) {
             CM_Service_Manager::getInstance()->getNewrelic()->startTransaction($transactionName);
             try {
                 $callback();
             } catch (CM_Exception $e) {
                 CM_Bootloader::getInstance()->getExceptionHandler()->handleException($e);
             }
             CM_Service_Manager::getInstance()->getNewrelic()->endTransaction();
         });
     }
 }
Esempio n. 3
0
 /**
  * @param string    $dateTimeString
  * @param Closure[] $callbacks
  */
 protected function _registerClockworkCallbacks($dateTimeString, $callbacks)
 {
     foreach ($callbacks as $name => $callback) {
         $transactionName = 'cm ' . static::getPackageName() . ' start: ' . $name;
         $this->_clockworkManager->registerCallback($name, $dateTimeString, function () use($transactionName, $callback) {
             CM_Service_Manager::getInstance()->getNewrelic()->startTransaction($transactionName);
             try {
                 call_user_func_array($callback, func_get_args());
             } catch (CM_Exception $e) {
                 CM_Service_Manager::getInstance()->getNewrelic()->endTransaction();
                 throw $e;
             }
             CM_Service_Manager::getInstance()->getNewrelic()->endTransaction();
         });
     }
 }