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(); } }
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); } }
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); } }
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; }
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; }
/** * @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); } }
static function run($configData) { self::init($configData); $router = Api_Core_Factory::createRouter(); $controllerName = $router->getControllerName(); $controllerClassName = "Api_Application_{$controllerName}_Controller"; $controller = new $controllerClassName(); $actionName = $router->getActionName(); $action = 'action' . $actionName; if (!method_exists($controller, $action)) { http_response_code(404); Api_Core_Application::end(); } $controller->{$action}(); }
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; }
<?php ini_set('display_errors', 1); error_reporting(E_ALL); $root = realpath(__DIR__ . '/../'); require_once $root . '/autoload.php'; set_time_limit(0); ignore_user_abort(true); $configData = (include $root . '/configs/config.php'); Api_Core_Application::init($configData); $job = new Job_Monitor(); $job->run();
<?php require_once './autoload.php'; ini_set('display_errors', 1); error_reporting(E_ALL); $configData = (include 'configs/config.php'); Api_Core_Application::run($configData);
public function actionGetLast() { $domainName = filter_input(INPUT_GET, 'domain_name'); $response = Api_Component_Factory::createResponse(); if (!$this->isHaveAccessForDomain(self::GET_LAST_ACTION, $domainName, INPUT_GET)) { $response->setError(true)->setSuccess(false)->addMessage("access denied"); http_response_code(403); echo $this->renderView('json', array('data' => $response->getData())); Api_Core_Application::end(); } $helper = new Api_Application_Api_Helper_Backup(); $storage = Api_Component_Factory::createFileStorage(); $files = $helper->getLastFileUrl($domainName, $storage); $lastFile = end($files); if (empty($lastFile)) { $response->setError(true)->setSuccess(false)->addMessage("file not found"); http_response_code(404); echo $this->renderView('json', array('data' => $response->getData())); } else { $url = $storage->getFileUrl($lastFile["file"]); if (ob_get_level()) { ob_end_clean(); } header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($lastFile["file"]) . '"'); header('Content-transfer-encoding: binary'); // Required? Not sure.. set_time_limit(60 * 50); if ($fd = fopen($url, 'r')) { while (!feof($fd)) { print fread($fd, 1024); } fclose($fd); } $storage->closeFileUrl($lastFile["file"]); Api_Core_Application::end(); } }