Esempio n. 1
0
 public static function isExtraDbExist($hostname)
 {
     $dbList = ServersData::getDbList($hostname);
     $connection = \Bitrix\Main\Application::getConnection();
     $currentDb = $connection->getDbName();
     $dbCount = count($dbList);
     if ($dbCount > 1 || $dbCount == 1 && !in_array($currentDb, $dbList)) {
         $result = true;
     } else {
         $result = false;
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Starts the action execution
  * @param array $inputParams
  * @return int code returned by shell
  * @throws \Bitrix\Main\ArgumentTypeException
  */
 public function start($inputParams = array())
 {
     if (!is_array($inputParams)) {
         throw new \Bitrix\Main\ArgumentTypeException("inputParams", "array");
     }
     if (isset($this->actionParams["CHECK_EXTRA_DB"]) && $this->actionParams["CHECK_EXTRA_DB"] == "Y") {
         $dbList = ServersData::getDbList($this->serverHostname);
         $connection = \Bitrix\Main\Application::getConnection();
         $currentDb = $connection->getDbName();
         $dbCount = count($dbList);
         if ($dbCount > 1 || $dbCount == 1 && !in_array($currentDb, $dbList)) {
             $error = Loc::getMessage("SCALE_ACTION_EXTRA_DB_EXIST");
             $this->makeLogRecords("", false, "", $error);
             throw new \Exception(Loc::getMessage("SCALE_ACTION_EXTRA_DB_EXIST"));
         }
     }
     $result = null;
     $command = $this->makeStartCommand($inputParams);
     $result = $this->shellAdapter->syncExec($command);
     $output = $this->shellAdapter->getLastOutput();
     $arOutput = array();
     if (strlen($output) > 0) {
         $arOut = json_decode($output, true);
         if (is_array($arOut) && !empty($arOut)) {
             $arOutput = $arOut;
         }
     }
     $error = $this->shellAdapter->getLastError();
     $this->makeLogRecords($command, $result, $output, $error);
     $this->result = array($this->id => array("NAME" => isset($this->actionParams["NAME"]) ? $this->actionParams["NAME"] : "[" . $this->id . "]", "RESULT" => $result ? "OK" : "ERROR", "OUTPUT" => array("TEXT" => $output, "DATA" => $arOutput), "ERROR" => $error));
     return $result;
 }