$tabControl = new CAdminTabControl("tabControl", $aTabs); $strError = ""; $bVarsFromForm = false; if (!extension_loaded('memcache')) { require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; ShowError(GetMessage("CLU_MEMCACHE_NO_EXTENTION")); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"; } if ($REQUEST_METHOD == "POST" && check_bitrix_sessid()) { if ($save != "" || $apply != "") { $ob = new CClusterMemcache(); $arFields = array("GROUP_ID" => $group_id, "HOST" => $_POST["HOST"], "PORT" => $_POST["PORT"], "WEIGHT" => $_POST["WEIGHT"]); if (is_array($arServer)) { $res = $ob->Update($arServer["ID"], $arFields); } else { $res = $ob->Add($arFields); } if ($res) { if ($apply != "") { LocalRedirect("/bitrix/admin/cluster_memcache_edit.php?ID=" . $res . "&lang=" . LANGUAGE_ID . '&group_id=' . $group_id . "&" . $tabControl->ActiveTabParam()); } else { LocalRedirect("/bitrix/admin/cluster_memcache_list.php?lang=" . LANGUAGE_ID . '&group_id=' . $group_id); } } else { if ($e = $APPLICATION->GetException()) { $message = new CAdminMessage(GetMessage("CLU_MEMCACHE_EDIT_SAVE_ERROR"), $e); } $bVarsFromForm = true; } } }
/** * Installation config to module "cluster". * * @param InputInterface $input * @param OutputInterface $output * @param array $cluster * * @throws \Bitrix\Main\LoaderException * @throws \Exception */ protected function configureCluster(InputInterface $input, OutputInterface $output, array $cluster) { global $APPLICATION; if (!Loader::includeModule('cluster')) { throw new \Exception('Failed to load module "cluster"'); } $memcache = new \CClusterMemcache(); if (isset($cluster['memcache'])) { $output->writeln(' <comment>memcache</comment>'); if (!is_array($cluster['memcache'])) { throw new \Exception('Server info must be an array'); } $rsServers = $memcache->GetList(); while ($server = $rsServers->Fetch()) { $memcache->Delete($server['ID']); } foreach ($cluster['memcache'] as $index => $server) { $serverId = $memcache->Add($server); if ($serverId && !$input->getOption('memcache-cold-start')) { $memcache->Resume($serverId); } else { $exception = $APPLICATION->GetException(); $message = 'Invalid memcache config with index ' . $index; if ($exception->GetString()) { $message = str_replace('<br>', "\n", $exception->GetString()); } $output->writeln('<error>' . $message . '</error>'); } } } }