删除反向代理

Signed-off-by: HITSword <admin@huayizhiyun.com>
master
HITSword 2020-01-17 18:58:38 +08:00
parent 9b0843f21b
commit 221452ffca
2 changed files with 37 additions and 2 deletions

View File

@ -85,7 +85,8 @@ function amh_module_admin()
fi; fi;
;; ;;
del) del)
echo "del something"; php ${module_dir}cli.php --action='del' --server_name=${domain}
amh nginx reload;
;; ;;
start-cache) start-cache)
echo "start cache"; echo "start cache";

36
cli.php
View File

@ -85,6 +85,7 @@
} }
/** /**
* 【完成】
* 新建反向代理 * 新建反向代理
* @param $server_name * @param $server_name
* @param string $proxy_pass * @param string $proxy_pass
@ -137,7 +138,7 @@
* @param string $value * @param string $value
* @return string * @return string
*/ */
function hyproxy_edit($server_name, $field_name = '', $value = '') function amproxy_edit($server_name, $field_name = '', $value = '')
{ {
if (empty($server_name)) { if (empty($server_name)) {
return "[Error] The server_name is empty.\n";//不能为空 return "[Error] The server_name is empty.\n";//不能为空
@ -178,4 +179,37 @@
} }
} }
return $res; return $res;
}
/**
* 删除反向代理
* @param $server_name
* @return string
*/
function hyproxy_del($server_name = null)
{
$res = '';
if (empty($server_name)) {
$res = "[Error] The server_name is empty.\n";//不能为空
} else {
global $medoo;
$table = 'module_hyproxy';
$columns = '*';
$where = array('server_name'=>trim($server_name));
$row = $medoo->get($table, $columns, $where);
if (empty($row)) {
$res = "[Error] $server_name AMProxy not exist!\n";//不存在
} else {
$mysqlres = $medoo->delete($table, $where);
if ($mysqlres) {
$res = "[OK] successfully delete $server_name AMProxy.\n";
} else {
$res = "[Error] error delete $server_name AMProxy.\n";
}
}
}
unlink(_HYCONF . $server_name . '.conf');//删除配置文件
unlink(_HYLOGS . $server_name . '.access.log');//删除日志文件
unlink(_HYLOGS . $server_name . '.error.log');//删除日志文件
return $res;
} }