- Модуль: scale
- Путь к файлу: ~/bitrix/modules/scale/lib/action.php
- Класс: BitrixScaleAction
- Вызов: Action::start
public function start(array $inputParams = array())
{
if(!is_array($inputParams))
throw new BitrixMainArgumentTypeException("inputParams", "array");
if(isset($this->actionParams["MODIFYERS"]) && is_array($this->actionParams["MODIFYERS"]))
{
$needMoreUserInfo = false;
foreach($this->actionParams["MODIFYERS"] as $modifyerFunction)
{
if(is_callable($modifyerFunction))
{
try
{
$this->actionParams = call_user_func($modifyerFunction, $this->id, $this->actionParams, $this->serverHostname, $this->userParams);
}
catch(NeedMoreUserInfoException $e)
{
$this->actionParams = $e->getActionParams();
$needMoreUserInfo = true;
}
}
}
if($needMoreUserInfo)
throw new NeedMoreUserInfoException("Need more user's info", $this->actionParams);
}
$result = null;
$output = '';
$arOutput = array();
$command = $this->makeStartCommand($inputParams);
if($command <> '')
{
$result = $this->shellAdapter->syncExec($command);
$output = $this->shellAdapter->getLastOutput();
$arOutput = array();
if($output <> '')
{
$arOut = json_decode($output, true);
if(is_array($arOut) && !empty($arOut))
$arOutput = $arOut;
}
//error returned by shell
$error = $this->shellAdapter->getLastError();
//error returned by bitrix-env
if(isset($arOutput["error"]) && intval($arOutput["error"]) > 0 && isset($arOutput["message"]) && $arOutput["message"] <> '')
$error .= " ".$arOutput["message"];
$this->makeLogRecords($command, $result, $output, $error);
}
else //$command == ''
{
$result = false;
$error = 'Cant't create command for action execution';
}
$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;
}