Ejemplo n.º 1
0
 protected function _backupData($store)
 {
     switch ($this->_serverLocation) {
         case 'local':
             $this->_out->logNotice("doing 'local' data backup");
             $this->_backupDataFromLocal($store);
             break;
         case 'remote':
             $this->_out->logNotice("doing 'remote' data backup");
             $this->_backupDataFromRemote($store);
             break;
         default:
             // try to detect best possibility
             $s = $this->_db->getAttribute(PDO::ATTR_CONNECTION_STATUS);
             $this->_out->logNotice("connection status: {$s}");
             if (stripos($s, "localhost") === false && stripos($s, "127.0.0.1") === false) {
                 // remote
                 $this->_out->logNotice("detected 'remote' data backup");
                 $this->_backupDataFromRemote($store);
             } else {
                 // maybe local will work
                 try {
                     $this->_out->logNotice("trying 'local' data backup");
                     $this->_backupDataFromLocal($store);
                 } catch (Exception $ex) {
                     $this->_out->logNotice("fallback to 'remote' data backup");
                     $this->_backupDataFromRemote($store);
                 }
             }
     }
 }
Ejemplo n.º 2
0
 public function unlock()
 {
     if (!flock($this->_file, LOCK_UN)) {
         $this->_output->logDebug(">>>NOTICE! FAILED to release lock");
         return false;
     }
     ftruncate($this->_file, 0);
     fclose($this->_file);
     $this->_output->logDebug(">>>File unlocked");
     return true;
 }
Ejemplo n.º 3
0
 public function run()
 {
     if ($this->_stopAt !== false) {
         return false;
     }
     $orders = $this->_roles;
     try {
         $this->_runPhase("init", $orders) && $this->_runPhase("refreshLocal", $orders) && $this->_runPhase("refreshRemote", $orders) && $this->_runPhase("compare", $orders) && $this->_runPhase("updateRemote", $orders) && $this->_runPhase("shutdown", $orders);
     } catch (Core_StopException $e) {
         // error message
         $this->_stopAt = $e;
         self::$out->logError($e->getMessage());
         return false;
     } catch (Exception $e) {
         $myE = new Core_StopException("", "engine init", null, Core_StopException::RETCODE_FOREIGN_EXCEPTION);
         $myE->setException($e);
         $this->_stopAt = $myE;
         throw $e;
     }
     $this->_lock->unlock();
     return true;
 }