예제 #1
0
 public function startAll()
 {
     Api_Core_Application::log("Стартуем воркеры");
     exec(ROOT_DIR . "/build/pake restart_workers 2>&1", $output, $status);
     if ($status) {
         Api_Core_Application::log("Не запустились воркеры", $output, Api_Component_Log_Logger::LEVEL_ERROR);
     }
 }
예제 #2
0
function run_worker_monitor()
{
    $workerStarter = Job_Monitor_Factory::createWorkerStarter();
    if (!$workerStarter->isRun()) {
        Api_Core_Application::log("Не запущенны воркеры", null, Api_Component_Log_Logger::LEVEL_ERROR);
        run_restart_workers();
    }
}
예제 #3
0
 public function runWorkerStarter()
 {
     $workerStarter = Job_Monitor_Factory::createWorkerStarter();
     if (!$workerStarter->isRun()) {
         Api_Core_Application::log("Не запущенны воркеры", null, Api_Component_Log_Logger::LEVEL_ERROR);
         $workerStarter->startAll();
         Api_Core_Application::log("Запустили воркеры", null, Api_Component_Log_Logger::LEVEL_ERROR);
     }
 }
예제 #4
0
 public function run()
 {
     Api_Core_Application::log("Домен " . $this->getDomainName() . ". Начинаем паковать.");
     if ($this->_domainValidation->isValid()) {
         $backupResult = $this->_domain->createBackup();
         if (!$backupResult['fail']) {
             Api_Core_Application::log("Архив {$backupResult['lastBackup']} создан");
             return $this->_upload($this->_domain->getLastBackupFullPath());
         }
         Api_Core_Application::log("Проблема с данными у домена " . $this->getDomainName(), $backupResult, Api_Component_Log_Logger::LEVEL_ERROR);
     }
     return false;
 }
예제 #5
0
 public function getFiles($remotePath)
 {
     $response = $this->_s3->list_objects($this->_bucket, array('prefix' => $remotePath));
     $files = array();
     if ($response->isOK()) {
         $i = 0;
         while ($object = $response->body->Contents[$i]) {
             $i++;
             $files[] = array('file' => (string) $object->Key, 'size' => (int) $object->Size, 'date' => (string) $object->LastModified);
         }
     } else {
         Api_Core_Application::log("Get files " . $remotePath, array('upload', array('header' => $response->header, 'status' => $response->status, 'body' => $response->body)), Api_Component_Log_Logger::LEVEL_ERROR);
     }
     return $files;
 }
예제 #6
0
/**
 * @param $job GearmanJob
 */
function run_backup($job)
{
    global $root;
    echo "Registering {$job->workload()}";
    $domainName = trim($job->workload());
    try {
        $backup = new Job_Backup($domainName);
        echo "starting {$domainName} \n";
        $result = $backup->run();
        echo "result {$domainName} \n";
        return $result;
    } catch (Exception $ex) {
        Api_Core_Application::log("Ошибка в выполнении задачи " . $ex->getMessage(), array('domainName' => $domainName), Api_Component_Log_Logger::LEVEL_ERROR);
    }
}
 public function isValid()
 {
     $errors = array();
     if (!is_dir($this->_domain->getDomainDir())) {
         $errors[] = $this->_domain->getDomainDir() . " domain dir does not exist";
     }
     if (!is_dir($this->_domain->getBuildDir())) {
         $errors[] = $this->_domain->getBuildDir() . " build dir does not exist";
     }
     if (count($errors) > 0) {
         Api_Core_Application::log("Валидация домена не прошла " . $this->_domain->getDomainName(), $errors, Api_Component_Log_Logger::LEVEL_ERROR);
         return false;
     }
     return true;
 }