优化配置格式和卸载插件时删除日志。

Signed-off-by: hitsword <admin@hitsword.com>
master
hitsword 2020-01-09 20:30:49 +08:00
parent 25d60bda15
commit c8c430d070
4 changed files with 29 additions and 24 deletions

View File

@ -280,6 +280,7 @@ function amh_module_uninstall()
#clean proxys #clean proxys
php ${module_dir}hyproxy-cli.php --action='uninstall'; php ${module_dir}hyproxy-cli.php --action='uninstall';
amh nginx reload;
#uninstall nginx modules #uninstall nginx modules
Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`; Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`;

View File

@ -13,6 +13,6 @@ server {
proxy_pass {$proxy_pass}; proxy_pass {$proxy_pass};
} }
access_log {$logs_path}.access.log combined; #access_log end access_log {$access_log_path} combined; #access_log end
error_log {$logs_path}.error.log crit; #error_log end error_log {$error_log_path} crit; #error_log end
} }

View File

@ -21,6 +21,6 @@ server {
proxy_cache_purge hyproxy $scheme://$host$1$is_args$args; proxy_cache_purge hyproxy $scheme://$host$1$is_args$args;
} }
access_log {$logs_path}.access.log combined; #access_log end access_log {$access_log_path} combined; #access_log end
error_log {$logs_path}.error.log crit; #error_log end error_log {$error_log_path} crit; #error_log end
} }

View File

@ -233,26 +233,26 @@
* @param $server_name * @param $server_name
* @return string * @return string
*/ */
function hyproxy_del($server_name) function hyproxy_del($server_name = null)
{ {
if (empty($server_name)) {
return "[ERROR] The server_name is empty.\n";//不能为空
}
$res = ''; $res = '';
global $medoo; if (empty($server_name)) {
$table = 'module_hyproxy'; $res = "[ERROR] The server_name is empty.\n";//不能为空
$columns = '*';
$where = array('server_name'=>trim($server_name));
$proxy = $medoo->get($table, $columns, $where);
if (empty($proxy)) {
return "[ERROR] The server_name is not exist.\n";//不存在
} else { } else {
$mysqlres = $medoo->delete($table, $where); global $medoo;
if ($mysqlres) { $table = 'module_hyproxy';
$res = "[OK] Proxy del success.\n"; $columns = '*';
$where = array('server_name'=>trim($server_name));
$row = $medoo->get($table, $columns, $where);
if (empty($row)) {
$res = "[ERROR] The server_name is not exist.\n";//不存在
} else { } else {
$res = "[ERROR] Proxy del error.\n"; $mysqlres = $medoo->delete($table, $where);
if ($mysqlres) {
$res = "[OK] Proxy del success.\n";
} else {
$res = "[ERROR] Proxy del error.\n";
}
} }
} }
unlink(_HYCONF . $server_name . '.conf');//删除配置文件 unlink(_HYCONF . $server_name . '.conf');//删除配置文件
@ -273,11 +273,13 @@
global $medoo; global $medoo;
$table = 'module_hyproxy'; $table = 'module_hyproxy';
$columns = array('hyproxy_id','server_name','status'); $columns = array('hyproxy_id','server_name','status');
$where = ''; $list = $medoo->select($table, $columns);
$list = $medoo->select($table, $columns, $where);
if (!empty($list)) { if (!empty($list)) {
$medoo->delete($table, null);
foreach ($list as $row) { foreach ($list as $row) {
hyproxy_del($row['server_name']); unlink(_HYCONF . $row['server_name'] . '.conf');//删除配置文件
unlink(_HYLOGS . $row['server_name'] . '.access.log');//删除日志文件
unlink(_HYLOGS . $row['server_name'] . '.error.log');//删除日志文件
} }
} }
return "[OK] All proxy del success.\n"; return "[OK] All proxy del success.\n";
@ -379,7 +381,9 @@
$conf = false; $conf = false;
if (!empty($row)) { if (!empty($row)) {
$row['logs_path'] = _HYLOGS . $row['server_name']; //定义日志完整路径
$row['access_log_path'] = _HYLOGS . $row['server_name'] . '.access.log';
$row['error_log_path'] = _HYLOGS . $row['server_name'] . '.error.log';
//判断使用哪个模板 //判断使用哪个模板
$template = false; $template = false;