diff --git a/AMHScript b/AMHScript index d9f7758..613d571 100644 --- a/AMHScript +++ b/AMHScript @@ -280,6 +280,7 @@ function amh_module_uninstall() #clean proxys php ${module_dir}hyproxy-cli.php --action='uninstall'; + amh nginx reload; #uninstall nginx modules Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`; diff --git a/conf/no_cache_template.conf b/conf/no_cache_template.conf index efe8c66..3922947 100644 --- a/conf/no_cache_template.conf +++ b/conf/no_cache_template.conf @@ -13,6 +13,6 @@ server { proxy_pass {$proxy_pass}; } - access_log {$logs_path}.access.log combined; #access_log end - error_log {$logs_path}.error.log crit; #error_log end + access_log {$access_log_path} combined; #access_log end + error_log {$error_log_path} crit; #error_log end } \ No newline at end of file diff --git a/conf/proxy_cache_template.conf b/conf/proxy_cache_template.conf index 2a8016e..3ad6e83 100644 --- a/conf/proxy_cache_template.conf +++ b/conf/proxy_cache_template.conf @@ -21,6 +21,6 @@ server { proxy_cache_purge hyproxy $scheme://$host$1$is_args$args; } - access_log {$logs_path}.access.log combined; #access_log end - error_log {$logs_path}.error.log crit; #error_log end + access_log {$access_log_path} combined; #access_log end + error_log {$error_log_path} crit; #error_log end } \ No newline at end of file diff --git a/hyproxy-cli.php b/hyproxy-cli.php index a91026b..c3261ab 100644 --- a/hyproxy-cli.php +++ b/hyproxy-cli.php @@ -233,26 +233,26 @@ * @param $server_name * @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 = ''; - global $medoo; - $table = 'module_hyproxy'; - $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";//不存在 + if (empty($server_name)) { + $res = "[ERROR] The server_name is empty.\n";//不能为空 } else { - $mysqlres = $medoo->delete($table, $where); - if ($mysqlres) { - $res = "[OK] Proxy del success.\n"; + global $medoo; + $table = 'module_hyproxy'; + $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 { - $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');//删除配置文件 @@ -273,11 +273,13 @@ global $medoo; $table = 'module_hyproxy'; $columns = array('hyproxy_id','server_name','status'); - $where = ''; - $list = $medoo->select($table, $columns, $where); + $list = $medoo->select($table, $columns); if (!empty($list)) { + $medoo->delete($table, null); 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"; @@ -379,7 +381,9 @@ $conf = false; 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;